elharo commented on code in PR #183:
URL: https://github.com/apache/maven-shared-jar/pull/183#discussion_r4229466672


##########
src/main/java/org/apache/maven/shared/jar/JarAnalyzer.java:
##########
@@ -89,7 +84,8 @@ public class JarAnalyzer {
     private final JarData jarData;
 
     /**
-     * Constructor. Opens the JAR file, so should be matched by a call to 
{@link #closeQuietly()}.
+     * Constructor. Opens the JAR file, so should be matched by a call to 
{@link #close()} or

Review Comment:
   teh doc comment here should mention try with resources



##########
src/test/java/org/apache/maven/shared/jar/JarAnalyzerTest.java:
##########
@@ -102,6 +103,21 @@ void closeTwice() throws Exception {
         });
     }
 
+    @Test
+    void closeCanBeUsedByTryWithResources() throws Exception {
+        JarAnalyzer closedAnalyzer;
+        JarEntry entry;
+        try (JarAnalyzer analyzer = getJarAnalyzer("codec.jar")) {
+            closedAnalyzer = analyzer;
+            entry = analyzer.getEntries().get(0);
+            try (InputStream stream = analyzer.getEntryInputStream(entry)) {
+                assertTrue(stream.read() >= 0);
+            }
+        }
+
+        assertThrows(IllegalStateException.class, () -> 
closedAnalyzer.getEntryInputStream(entry));

Review Comment:
   This should really be an IOException, but that's a separate issue I suppose



##########
src/main/java/org/apache/maven/shared/jar/JarAnalyzer.java:
##########
@@ -33,21 +34,15 @@
 import java.util.zip.ZipEntry;
 
 /**
- * Open a JAR file to be analyzed. Note that once created, the {@link 
#closeQuietly()} method should be called to
- * release the associated file handle.
+ * Open a JAR file to be analyzed. The associated file handle should be closed 
when analysis is complete.
  *
  * Typical usage:
  * <pre>
- *  JarAnalyzer jar = new JarAnalyzer( jarFile );

Review Comment:
   jarClasses should be inside the try block



-- 
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