Fix a resource leak
This issue was found by scan.coverity.com (CID 19968) which is a static code analysis tool, free for open source code. Change-Id: I1ec2b191507d80b7fc3101afb9d4925afb570360
This commit is contained in:
@@ -43,6 +43,7 @@ import org.eclipse.jgit.lib.ObjectId;
|
|||||||
import org.eclipse.jgit.lib.ObjectInserter;
|
import org.eclipse.jgit.lib.ObjectInserter;
|
||||||
import org.eclipse.jgit.lib.ObjectLoader;
|
import org.eclipse.jgit.lib.ObjectLoader;
|
||||||
import org.eclipse.jgit.lib.ObjectReader;
|
import org.eclipse.jgit.lib.ObjectReader;
|
||||||
|
import org.eclipse.jgit.lib.ObjectStream;
|
||||||
import org.eclipse.jgit.notes.Note;
|
import org.eclipse.jgit.notes.Note;
|
||||||
import org.eclipse.jgit.notes.NoteMerger;
|
import org.eclipse.jgit.notes.NoteMerger;
|
||||||
import org.eclipse.jgit.util.io.UnionInputStream;
|
import org.eclipse.jgit.util.io.UnionInputStream;
|
||||||
@@ -67,12 +68,13 @@ class ReviewNoteMerger implements NoteMerger {
|
|||||||
ObjectLoader lo = reader.open(ours.getData());
|
ObjectLoader lo = reader.open(ours.getData());
|
||||||
byte[] sep = new byte[] {'\n'};
|
byte[] sep = new byte[] {'\n'};
|
||||||
ObjectLoader lt = reader.open(theirs.getData());
|
ObjectLoader lt = reader.open(theirs.getData());
|
||||||
UnionInputStream union = new UnionInputStream(
|
try (ObjectStream os = lo.openStream();
|
||||||
lo.openStream(),
|
ByteArrayInputStream b = new ByteArrayInputStream(sep);
|
||||||
new ByteArrayInputStream(sep),
|
ObjectStream ts = lt.openStream();
|
||||||
lt.openStream());
|
UnionInputStream union = new UnionInputStream(os, b, ts)) {
|
||||||
ObjectId noteData = inserter.insert(Constants.OBJ_BLOB,
|
ObjectId noteData = inserter.insert(Constants.OBJ_BLOB,
|
||||||
lo.getSize() + sep.length + lt.getSize(), union);
|
lo.getSize() + sep.length + lt.getSize(), union);
|
||||||
return new Note(ours, noteData);
|
return new Note(ours, noteData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user