]> WPIA git - gigi.git/blobdiff - src/org/cacert/gigi/output/template/Template.java
fix: free resource when template loading fails.
[gigi.git] / src / org / cacert / gigi / output / template / Template.java
index 15f3408d28ce41d10d55b4f9491fdaf223cb0d84..e80885710959c0ce23ba67c02350b4f94a6d39e7 100644 (file)
@@ -75,8 +75,7 @@ public class Template implements Outputable {
      *            the URL to load the template from. UTF-8 is chosen as charset.
      */
     public Template(URL u) {
-        try {
-            Reader r = new InputStreamReader(u.openStream(), "UTF-8");
+        try (Reader r = new InputStreamReader(u.openStream(), "UTF-8")) {
             try {
                 if (u.getProtocol().equals("file")) {
                     source = new File(u.toURI());
@@ -86,7 +85,6 @@ public class Template implements Outputable {
                 e.printStackTrace();
             }
             data = parse(r).getBlock(null);
-            r.close();
         } catch (IOException e) {
             throw new Error(e);
         }