mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
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:
@@ -38,13 +38,11 @@ public class CMISUtils
|
|||||||
public static <T> T copy(T source)
|
public static <T> T copy(T source)
|
||||||
{
|
{
|
||||||
T target = null;
|
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.writeObject(source);
|
||||||
out.flush();
|
out.flush();
|
||||||
out.close();
|
|
||||||
|
|
||||||
ObjectInputStream in = new ObjectInputStream(cos.getInputStream());
|
ObjectInputStream in = new ObjectInputStream(cos.getInputStream());
|
||||||
target = (T) in.readObject();
|
target = (T) in.readObject();
|
||||||
|
Reference in New Issue
Block a user