Merge pull request #20 from Alfresco/fix/Sonar-Close-Open-Streams

Use java 7 try with resource for closing the streams properly
This commit is contained in:
Martin Muller
2018-07-09 12:24:12 +01:00
committed by GitHub

View File

@@ -38,13 +38,11 @@ public class CMISUtils
public static <T> T copy(T source)
{
T target = null;
try
try ( CopyOutputStream cos = new CopyOutputStream();
ObjectOutputStream out = new ObjectOutputStream(cos) )
{
CopyOutputStream cos = new CopyOutputStream();
ObjectOutputStream out = new ObjectOutputStream(cos);
out.writeObject(source);
out.flush();
out.close();
ObjectInputStream in = new ObjectInputStream(cos.getInputStream());
target = (T) in.readObject();