Use Java 7 try-with-resources in InitPluginStepsLoader
The try-with-resources statement ensures that the created resources
are always closed. Thus we can remove the suppression of Eclipse's
warnings about unclosed resources.
Change-Id: Ib20620d35e2b18fd061f6b1ea4d97eb9a00003bc
diff --git a/gerrit-pgm/src/main/java/com/google/gerrit/pgm/init/InitPluginStepsLoader.java b/gerrit-pgm/src/main/java/com/google/gerrit/pgm/init/InitPluginStepsLoader.java
index 85a8ee3..39a6b9b 100644
--- a/gerrit-pgm/src/main/java/com/google/gerrit/pgm/init/InitPluginStepsLoader.java
+++ b/gerrit-pgm/src/main/java/com/google/gerrit/pgm/init/InitPluginStepsLoader.java
@@ -65,13 +65,12 @@
return pluginsInitSteps;
}
- @SuppressWarnings("resource")
private InitStep loadInitStep(File jar) {
- try {
- ClassLoader pluginLoader =
- new URLClassLoader(new URL[] {jar.toURI().toURL()},
- InitPluginStepsLoader.class.getClassLoader());
- JarFile jarFile = new JarFile(jar);
+ try (URLClassLoader pluginLoader =
+ new URLClassLoader(new URL[] {jar.toURI().toURL()},
+ InitPluginStepsLoader.class.getClassLoader());
+ JarFile jarFile = new JarFile(jar);) {
+
Attributes jarFileAttributes = jarFile.getManifest().getMainAttributes();
String initClassName = jarFileAttributes.getValue("Gerrit-InitStep");
if (initClassName == null) {