]> source.dussan.org Git - archiva.git/commitdiff
close StringReader
authorOlivier Lamy <olamy@apache.org>
Fri, 6 Jan 2012 08:56:03 +0000 (08:56 +0000)
committerOlivier Lamy <olamy@apache.org>
Fri, 6 Jan 2012 08:56:03 +0000 (08:56 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1228022 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultCommonServices.java

index 92f56e11e8ef7804719413c5c848a0e4ec9573cd..b768807fdfbfc9b43b7e307559fe0bd5ff541caf 100644 (file)
@@ -29,7 +29,6 @@ import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
 
 import javax.inject.Inject;
-import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.Response;
 import java.io.IOException;
 import java.io.InputStream;
@@ -124,18 +123,34 @@ public class DefaultCommonServices
             String redbackProps = utilServices.getI18nResources( locale );
             String archivaProps = getI18nResources( locale );
             Properties properties = new Properties();
-            properties.load( new StringReader( redbackProps ) );
-            properties.load( new StringReader( archivaProps ) );
+            loadFromString( redbackProps, properties );
+            loadFromString( archivaProps, properties );
             return fromProperties( properties );
         }
         catch ( RedbackServiceException e )
         {
             throw new ArchivaRestServiceException( e.getMessage(), e.getHttpErrorCode() );
         }
+    }
+
+    private void loadFromString( String propsStr, Properties properties )
+        throws ArchivaRestServiceException
+    {
+
+        StringReader stringReader = null;
+        try
+        {
+            stringReader = new StringReader( propsStr );
+            properties.load( stringReader );
+        }
         catch ( IOException e )
         {
             throw new ArchivaRestServiceException( e.getMessage(),
                                                    Response.Status.INTERNAL_SERVER_ERROR.getStatusCode() );
         }
+        finally
+        {
+            IOUtils.closeQuietly( stringReader );
+        }
     }
 }