@@ -47,25 +47,31 @@ public void setup(@TempDir Path tmpDir) throws IOException {
4747 @ Test
4848 @ DisplayName ("can load resources from both jars" )
4949 public void testForPluginDirWithPath () throws IOException {
50- var cl = ClassLoaderFactory .forPluginDirWithPath (pluginDir );
51- var fooContents = cl .getResourceAsStream ("foo.properties" ).readAllBytes ();
52- var barContents = cl .getResourceAsStream ("bar.properties" ).readAllBytes ();
53-
54- Assertions .assertArrayEquals (FOO_CONTENTS , fooContents );
55- Assertions .assertArrayEquals (BAR_CONTENTS , barContents );
50+ try (var cl = ClassLoaderFactory .forPluginDirWithPath (pluginDir );
51+ var fooIn = cl .getResourceAsStream ("foo.properties" );
52+ var barIn = cl .getResourceAsStream ("bar.properties" )) {
53+ var fooContents = fooIn .readAllBytes ();
54+ var barContents = barIn .readAllBytes ();
55+
56+ Assertions .assertArrayEquals (FOO_CONTENTS , fooContents );
57+ Assertions .assertArrayEquals (BAR_CONTENTS , barContents );
58+ }
5659 }
5760
5861 @ Test
5962 @ DisplayName ("can load resources when path is set in cryptomator.pluginDir" )
6063 public void testForPluginDirFromSysProp () throws IOException {
6164 System .setProperty ("cryptomator.pluginDir" , pluginDir .toString ());
6265
63- var cl = ClassLoaderFactory .forPluginDir ();
64- var fooContents = cl .getResourceAsStream ("foo.properties" ).readAllBytes ();
65- var barContents = cl .getResourceAsStream ("bar.properties" ).readAllBytes ();
66+ try (var cl = ClassLoaderFactory .forPluginDir ();
67+ var fooIn = cl .getResourceAsStream ("foo.properties" );
68+ var barIn = cl .getResourceAsStream ("bar.properties" )) {
69+ var fooContents = fooIn .readAllBytes ();
70+ var barContents = barIn .readAllBytes ();
6671
67- Assertions .assertArrayEquals (FOO_CONTENTS , fooContents );
68- Assertions .assertArrayEquals (BAR_CONTENTS , barContents );
72+ Assertions .assertArrayEquals (FOO_CONTENTS , fooContents );
73+ Assertions .assertArrayEquals (BAR_CONTENTS , barContents );
74+ }
6975 }
7076 }
7177
@@ -126,7 +132,7 @@ public void testFindJars2(@TempDir Path tmpDir) throws IOException {
126132 var urls = ClassLoaderFactory .findJars (tmpDir );
127133
128134 Arrays .sort (urls , Comparator .comparing (URL ::toString ));
129- Assertions .assertArrayEquals (new URL []{
135+ Assertions .assertArrayEquals (new URL [] {
130136 new URL (tmpDir .toUri () + "a.jar" ),
131137 new URL (tmpDir .toUri () + "dir2/b.jar" )
132138 }, urls );
0 commit comments