elharo commented on code in PR #183:
URL: https://github.com/apache/maven-shared-jar/pull/183#discussion_r4719984185
##########
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(IOException.class, () ->
closedAnalyzer.getEntryInputStream(entry));
Review Comment:
move this into try block and don't split variable initializations
##########
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;
Review Comment:
decalre this where it's initialized
--
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]