From d5461dcc538f604cfd1c7b7ed0b74181932f96e0 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Fri, 6 Jan 2012 08:56:03 +0000 Subject: [PATCH] close StringReader git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1228022 13f79535-47bb-0310-9956-ffa450edef68 --- .../rest/services/DefaultCommonServices.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultCommonServices.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultCommonServices.java index 92f56e11e..b768807fd 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultCommonServices.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultCommonServices.java @@ -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 ); + } } } -- 2.39.5