← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11887: Fixing potential resource leak in StreamUtils

 

------------------------------------------------------------
revno: 11887
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-09-03 20:34:13 +0200
message:
  Fixing potential resource leak in StreamUtils
modified:
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/StreamUtils.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/StreamUtils.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/StreamUtils.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/StreamUtils.java	2013-09-03 18:34:13 +0000
@@ -237,9 +237,11 @@
      */
     public static String getContent( File file )
     {
+        BufferedInputStream in = null;
+        
         try
         {
-            BufferedInputStream in = new BufferedInputStream( new FileInputStream( file ) );
+            in = new BufferedInputStream( new FileInputStream( file ) );
 
             byte[] bytes = new byte[(int) file.length()];
 
@@ -251,6 +253,10 @@
         {
             throw new RuntimeException( ex );
         }
+        finally
+        {
+            closeInputStream( in );
+        }
     }
 
     /**