← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18373: CacheManifestAction, using try-with-resources to avoid resource leak

 

------------------------------------------------------------
revno: 18373
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2015-02-22 21:30:29 +0100
message:
  CacheManifestAction, using try-with-resources to avoid resource leak
modified:
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/appcache/CacheManifestAction.java
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/security/DefaultAuthenticationSuccessHandler.java
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/security/intercept/XWorkSecurityInterceptor.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetMetaDataAction.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-commons/src/main/java/org/hisp/dhis/appcache/CacheManifestAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/appcache/CacheManifestAction.java	2015-01-22 16:55:07 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/appcache/CacheManifestAction.java	2015-02-22 20:30:29 +0000
@@ -52,7 +52,6 @@
 public class CacheManifestAction
     implements Action
 {
-
     @Autowired
     private UserSettingService userSettingService;
 
@@ -138,10 +137,8 @@
 
         if ( cacheManifest != null )
         {
-            try
+            try ( BufferedReader bufferedReader = new BufferedReader( new FileReader( cacheManifest ) ) )
             {
-                FileReader fileReader = new FileReader( cacheManifest );
-                BufferedReader bufferedReader = new BufferedReader( fileReader );
                 stringBuffer = new StringBuffer();
                 String line;
                 while ( (line = bufferedReader.readLine()) != null )
@@ -152,8 +149,6 @@
                 stringBuffer.append( revisionTag );
                 stringBuffer.append( "\n" );
 
-                fileReader.close();
-
                 if ( i18nFolder != null )
                 {
                     File[] i18nfiles = i18nFolder.listFiles();
@@ -186,7 +181,6 @@
             {
                 e.printStackTrace();
             }
-
         }
 
         stringBuffer = new StringBuffer();

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/security/DefaultAuthenticationSuccessHandler.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/security/DefaultAuthenticationSuccessHandler.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/security/DefaultAuthenticationSuccessHandler.java	2015-02-22 20:30:29 +0000
@@ -54,7 +54,7 @@
      * client, since entering data can take time, and data will be lost if the session
      * times out while entering data.
      */
-    public static int DEFAULT_SESSION_TIMEOUT = 60 * 60;
+    public static final int DEFAULT_SESSION_TIMEOUT = 60 * 60;
 
     @Override
     public void onAuthenticationSuccess( HttpServletRequest request, HttpServletResponse response, Authentication authentication )

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/security/intercept/XWorkSecurityInterceptor.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/security/intercept/XWorkSecurityInterceptor.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/security/intercept/XWorkSecurityInterceptor.java	2015-02-22 20:30:29 +0000
@@ -58,7 +58,7 @@
 
     private static final String KEY_SECURITY_SERVICE = "security";
 
-    private ThreadLocal<SecurityMetadataSource> definitionSourceTag = new ThreadLocal<>();
+    private final ThreadLocal<SecurityMetadataSource> definitionSourceTag = new ThreadLocal<>();
 
     // -------------------------------------------------------------------------
     // Dependencies

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetMetaDataAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetMetaDataAction.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetMetaDataAction.java	2015-02-22 20:30:29 +0000
@@ -28,6 +28,8 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import static org.hisp.dhis.system.util.TextUtils.SEP;
+
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -41,7 +43,6 @@
 import org.apache.struts2.ServletActionContext;
 import org.hisp.dhis.common.IdentifiableObjectManager;
 import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
-import org.hisp.dhis.configuration.ConfigurationService;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementCategory;
 import org.hisp.dhis.dataelement.DataElementCategoryCombo;
@@ -62,8 +63,6 @@
 
 import com.opensymphony.xwork2.Action;
 
-import static org.hisp.dhis.system.util.TextUtils.SEP;
-
 /**
  * @author Lars Helge Overland
  */
@@ -117,9 +116,6 @@
     }
 
     @Autowired
-    private ConfigurationService configurationService;
-
-    @Autowired
     private IdentifiableObjectManager identifiableObjectManager;
     
     // -------------------------------------------------------------------------