dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #31666
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16171: AddAppAction, fixed potential resource leak
------------------------------------------------------------
revno: 16171
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2014-07-18 13:32:11 +0200
message:
AddAppAction, fixed potential resource leak
modified:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-appmanager/src/main/java/org/hisp/dhis/appmanager/action/AddAppAction.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-maintenance/dhis-web-maintenance-appmanager/src/main/java/org/hisp/dhis/appmanager/action/AddAppAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-appmanager/src/main/java/org/hisp/dhis/appmanager/action/AddAppAction.java 2014-07-18 11:19:25 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-appmanager/src/main/java/org/hisp/dhis/appmanager/action/AddAppAction.java 2014-07-18 11:32:11 +0000
@@ -119,35 +119,33 @@
return FAILURE;
}
- ZipFile zip = new ZipFile( file );
- ZipEntry entry = zip.getEntry( "manifest.webapp" );
-
- if ( entry == null)
- {
- zip.close();
- message = i18n.getString( "appmanager_manifest_not_found" );
- log.warn( "Manifest file could not be found in app" );
- return FAILURE;
- }
-
- try
- {
- appManager.installApp( file, fileName, getRootPath() );
+ try ( ZipFile zip = new ZipFile( file ) )
+ {
+ ZipEntry entry = zip.getEntry( "manifest.webapp" );
+
+ if ( entry == null)
+ {
+ zip.close();
+ message = i18n.getString( "appmanager_manifest_not_found" );
+ log.warn( "Manifest file could not be found in app" );
+ return FAILURE;
+ }
- message = i18n.getString( "appmanager_install_success" );
- }
- catch ( JsonParseException ex )
- {
- message = i18n.getString( "appmanager_invalid_json" );
- log.error( "Error parsing JSON in manifest", ex );
- return FAILURE;
- }
- finally
- {
- zip.close();
- }
-
- return SUCCESS;
+ try
+ {
+ appManager.installApp( file, fileName, getRootPath() );
+
+ message = i18n.getString( "appmanager_install_success" );
+
+ return SUCCESS;
+ }
+ catch ( JsonParseException ex )
+ {
+ message = i18n.getString( "appmanager_invalid_json" );
+ log.error( "Error parsing JSON in manifest", ex );
+ return FAILURE;
+ }
+ }
}
private String getRootPath()