dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #22038
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10560: Fixed potential resource leak in DefaultResourceBundleManager
------------------------------------------------------------
revno: 10560
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-04-15 18:18:27 +0200
message:
Fixed potential resource leak in DefaultResourceBundleManager
modified:
dhis-2/dhis-services/dhis-service-i18n/src/main/java/org/hisp/dhis/i18n/resourcebundle/DefaultResourceBundleManager.java
dhis-2/dhis-services/dhis-service-integration/src/test/java/org/hisp/dhis/integration/RoutesTest.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-services/dhis-service-i18n/src/main/java/org/hisp/dhis/i18n/resourcebundle/DefaultResourceBundleManager.java'
--- dhis-2/dhis-services/dhis-service-i18n/src/main/java/org/hisp/dhis/i18n/resourcebundle/DefaultResourceBundleManager.java 2013-02-03 07:37:51 +0000
+++ dhis-2/dhis-services/dhis-service-i18n/src/main/java/org/hisp/dhis/i18n/resourcebundle/DefaultResourceBundleManager.java 2013-04-15 16:18:27 +0000
@@ -27,6 +27,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.apache.commons.io.IOUtils;
import org.hisp.dhis.i18n.locale.LocaleManager;
import org.hisp.dhis.i18n.util.PathUtils;
@@ -148,35 +149,39 @@
private Collection<Locale> getAvailableLocalesFromJar( URL url )
throws ResourceBundleManagerException
{
- JarFile jar;
+ JarFile jar = null;
+
+ Set<Locale> availableLocales = new HashSet<Locale>();
try
{
JarURLConnection connection = (JarURLConnection) url.openConnection();
jar = connection.getJarFile();
+
+ Enumeration<JarEntry> e = jar.entries();
+
+ while ( e.hasMoreElements() )
+ {
+ JarEntry entry = e.nextElement();
+
+ String name = entry.getName();
+
+ if ( name.startsWith( globalResourceBundleName ) && name.endsWith( EXT_RESOURCE_BUNDLE ) )
+ {
+ availableLocales.add( getLocaleFromName( name ) );
+ }
+ }
}
catch ( IOException e )
{
throw new ResourceBundleManagerException( "Failed to get jar file: " + url, e );
}
-
- Set<Locale> availableLocales = new HashSet<Locale>();
-
- Enumeration<JarEntry> e = jar.entries();
-
- while ( e.hasMoreElements() )
+ finally
{
- JarEntry entry = e.nextElement();
-
- String name = entry.getName();
-
- if ( name.startsWith( globalResourceBundleName ) && name.endsWith( EXT_RESOURCE_BUNDLE ) )
- {
- availableLocales.add( getLocaleFromName( name ) );
- }
+ IOUtils.closeQuietly( jar );
}
-
+
return availableLocales;
}
=== modified file 'dhis-2/dhis-services/dhis-service-integration/src/test/java/org/hisp/dhis/integration/RoutesTest.java'
--- dhis-2/dhis-services/dhis-service-integration/src/test/java/org/hisp/dhis/integration/RoutesTest.java 2013-03-16 15:21:47 +0000
+++ dhis-2/dhis-services/dhis-service-integration/src/test/java/org/hisp/dhis/integration/RoutesTest.java 2013-04-15 16:18:27 +0000
@@ -27,9 +27,12 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import static org.hisp.dhis.common.IdentifiableObject.IdentifiableProperty.CODE;
+import static org.hisp.dhis.importexport.ImportStrategy.NEW_AND_UPDATES;
+import static org.junit.Assert.assertNotNull;
+
import org.hisp.dhis.DhisTest;
import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
import org.hisp.dhis.dataelement.DataElementCategoryService;
import org.hisp.dhis.dataelement.DataElementService;
import org.hisp.dhis.dataset.CompleteDataSetRegistrationService;
@@ -43,15 +46,10 @@
import org.hisp.dhis.period.MonthlyPeriodType;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodService;
-import org.junit.Ignore;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
-import static org.hisp.dhis.common.IdentifiableObject.IdentifiableProperty.CODE;
-import static org.hisp.dhis.importexport.ImportStrategy.NEW_AND_UPDATES;
-import static org.junit.Assert.assertNotNull;
-
public class RoutesTest
extends DhisTest
{
@@ -87,7 +85,6 @@
private OrganisationUnit ouB;
private Period peA;
private Period peB;
- private DataElementCategoryOptionCombo optionComboA;
@Override
public boolean emptyDatabaseAfterTest()
@@ -106,7 +103,6 @@
ouB = createOrganisationUnit( 'B' );
peA = createPeriod( getDate( 2012, 1, 1 ), getDate( 2012, 1, 31 ) );
peB = createPeriod( getDate( 2012, 2, 1 ), getDate( 2012, 2, 29 ) );
- optionComboA = categoryService.getDefaultDataElementCategoryOptionCombo();
deA.setUid( "f7n9E0hX8qk" );
deB.setUid( "Ix2HsbDMLea" );