← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10589: Handled potential resource leak in ContextUtils

 

------------------------------------------------------------
revno: 10589
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-04-16 20:19:38 +0200
message:
  Handled potential resource leak in ContextUtils
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ContextUtils.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-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ContextUtils.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ContextUtils.java	2013-02-25 12:33:35 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ContextUtils.java	2013-04-16 18:19:38 +0000
@@ -28,6 +28,8 @@
  */
 
 import javassist.util.proxy.ProxyObject;
+
+import org.apache.commons.io.IOUtils;
 import org.hisp.dhis.common.IdentifiableObject;
 import org.hisp.dhis.dxf2.metadata.ExchangeClasses;
 import org.hisp.dhis.setting.SystemSettingManager;
@@ -181,9 +183,11 @@
         response.setStatus( statusCode );
         response.setContentType( CONTENT_TYPE_TEXT );
 
+        PrintWriter writer = null;
+        
         try
         {
-            PrintWriter writer = response.getWriter();
+            writer = response.getWriter();
             writer.println( message );
             writer.flush();
         }
@@ -191,6 +195,10 @@
         {
             // Ignore
         }
+        finally
+        {
+            IOUtils.closeQuietly( writer );
+        }
     }
 
     public static HttpServletRequest getRequest()