elharo opened a new issue, #139:
URL: https://github.com/apache/maven-shared-jar/issues/139

   In `JarAnalyzer.java`, the constructor opens a `JarFile` and then sorts 
entries:
   
   ```java
   List<JarEntry> entries = Collections.list(jarFile.entries());
   entries.sort(Comparator.comparing(ZipEntry::getName));  // NPE if entry has 
null name
   ```
   
   If any `JarEntry` has a `null` name (possible in malformed ZIPs), 
`Comparator.comparing` throws NPE before the `getManifest()` try/catch block is 
reached. The `JarFile` handle is never closed, causing a resource leak.
   
   **Fix**: Either validate entry names before sorting, or use a null-safe 
comparator:
   ```java
   entries.sort(Comparator.comparing(ZipEntry::getName, 
Comparator.nullsLast(Comparator.naturalOrder())));
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to