mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-09 15:05:44 +01:00
use java7 auto close
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package sonia.scm.resources;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
@@ -151,21 +152,14 @@ public abstract class AbstractResourceServlet extends HttpServlet
|
||||
{
|
||||
response.setContentType(resource.getType().getContentType());
|
||||
|
||||
OutputStream output = null;
|
||||
|
||||
try
|
||||
try (OutputStream output = response.getOutputStream())
|
||||
{
|
||||
output = response.getOutputStream();
|
||||
resource.copyTo(output);
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtil.close(output);
|
||||
}
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private ResourceManager resourceManager;
|
||||
private final ResourceManager resourceManager;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,6 @@ package sonia.scm.resources;
|
||||
|
||||
import sonia.scm.plugin.PluginLoader;
|
||||
import sonia.scm.util.ChecksumUtil;
|
||||
import sonia.scm.util.IOUtil;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
@@ -72,19 +71,13 @@ public final class DefaultResource extends AbstractResource
|
||||
super(pluginLoader, resources, resourceHandlers);
|
||||
this.type = type;
|
||||
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
|
||||
try
|
||||
try (ByteArrayOutputStream baos = new ByteArrayOutputStream())
|
||||
{
|
||||
appendResources(baos);
|
||||
this.content = baos.toByteArray();
|
||||
this.name = ChecksumUtil.createChecksum(this.content).concat(".").concat(
|
||||
type.getExtension());
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtil.close(baos);
|
||||
}
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user