Fixed a possible unclosed IO stream.
1.1 --- a/licensechanger/src/org/netbeans/modules/licensechanger/api/LicenseHeader.java Thu Sep 13 09:10:03 2012 +0200
1.2 +++ b/licensechanger/src/org/netbeans/modules/licensechanger/api/LicenseHeader.java Thu Sep 13 09:19:41 2012 +0200
1.3 @@ -58,7 +58,7 @@
1.4 public static LicenseHeader fromFileObject(FileObject file, String licenseName, boolean isNetBeansTemplate) {
1.5 String name = licenseName==null?file.getName():licenseName;
1.6 String content;
1.7 - InputStream in;
1.8 + InputStream in = null;
1.9 try {
1.10 in = new BufferedInputStream(file.getInputStream());
1.11 ByteArrayOutputStream out = new ByteArrayOutputStream();
1.12 @@ -69,6 +69,14 @@
1.13 } catch (IOException ex) {
1.14 Exceptions.printStackTrace(ex);
1.15 return null;
1.16 + } finally {
1.17 + try {
1.18 + if(in!=null) {
1.19 + in.close();
1.20 + }
1.21 + } catch (IOException ex) {
1.22 + Exceptions.printStackTrace(ex);
1.23 + }
1.24 }
1.25 }
1.26
1.27 @@ -110,7 +118,9 @@
1.28 Exceptions.printStackTrace(ex);
1.29 } finally {
1.30 try {
1.31 - bos.close();
1.32 + if(bos!=null) {
1.33 + bos.close();
1.34 + }
1.35 } catch (IOException ex) {
1.36 Exceptions.printStackTrace(ex);
1.37 }