Close streams.
diff --git a/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/url/WebBundleUrlStreamHandlerServiceTests.java b/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/url/WebBundleUrlStreamHandlerServiceTests.java
index 2cfcb5f..d285b2c 100644
--- a/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/url/WebBundleUrlStreamHandlerServiceTests.java
+++ b/org.eclipse.gemini.web.core/src/test/java/org/eclipse/gemini/web/internal/url/WebBundleUrlStreamHandlerServiceTests.java
@@ -51,15 +51,16 @@
URLConnection connection = url.toURL().openConnection();
assertNotNull(connection);
- InputStream inputStream = connection.getInputStream();
- JarInputStream jarInputStream = new JarInputStream(inputStream);
- Manifest manifest = jarInputStream.getManifest();
+ try (InputStream inputStream = connection.getInputStream();
+ JarInputStream jarInputStream = new JarInputStream(inputStream);) {
+ Manifest manifest = jarInputStream.getManifest();
- if (manifest != null) {
- Attributes mainAttributes = manifest.getMainAttributes();
- Set<Entry<Object, Object>> entrySet = mainAttributes.entrySet();
- for (Entry<Object, Object> entry : entrySet) {
- System.out.println(entry.getKey() + ": " + entry.getValue());
+ if (manifest != null) {
+ Attributes mainAttributes = manifest.getMainAttributes();
+ Set<Entry<Object, Object>> entrySet = mainAttributes.entrySet();
+ for (Entry<Object, Object> entry : entrySet) {
+ System.out.println(entry.getKey() + ": " + entry.getValue());
+ }
}
}
}