@@ -67,26 +67,25 @@ protected String buildFinalTestSourceName(final String projectName) {
6767 }
6868
6969 protected void assertJarContent (final File jarFile , final String [] expectedFiles ) throws IOException {
70- ZipFile jar = new ZipFile (jarFile );
71- Enumeration <? extends ZipEntry > entries = jar .entries ();
70+ try ( ZipFile jar = new ZipFile (jarFile )) {
71+ Enumeration <? extends ZipEntry > entries = jar .entries ();
7272
73- if (expectedFiles .length == 0 ) {
74- assertFalse (entries .hasMoreElements (), "Jar file should not contain any entry" );
75- } else {
76- assertTrue (entries .hasMoreElements ());
73+ if (expectedFiles .length == 0 ) {
74+ assertFalse (entries .hasMoreElements (), "Jar file should not contain any entry" );
75+ } else {
76+ assertTrue (entries .hasMoreElements ());
7777
78- Set <String > expected = new TreeSet <>(Arrays .asList (expectedFiles ));
78+ Set <String > expected = new TreeSet <>(Arrays .asList (expectedFiles ));
7979
80- while (entries .hasMoreElements ()) {
81- ZipEntry entry = entries .nextElement ();
80+ while (entries .hasMoreElements ()) {
81+ ZipEntry entry = entries .nextElement ();
8282
83- assertTrue (expected .remove (entry .getName ()), "Not expecting " + entry .getName () + " in " + jarFile );
84- }
83+ assertTrue (expected .remove (entry .getName ()), "Not expecting " + entry .getName () + " in " + jarFile );
84+ }
8585
86- assertTrue (expected .isEmpty (), "Missing entries " + expected + " in " + jarFile );
86+ assertTrue (expected .isEmpty (), "Missing entries " + expected + " in " + jarFile );
87+ }
8788 }
88-
89- jar .close ();
9089 }
9190
9291 protected File getTestTargetDir (String projectName ) {
0 commit comments