close StringReader

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1228022 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-01-06 08:56:03 +00:00
parent bcf944afb6
commit d5461dcc53
1 changed files with 18 additions and 3 deletions

View 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 );
}
}
}