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.ObjectLoader;
 | 
			
		||||
import org.eclipse.jgit.lib.ObjectReader;
 | 
			
		||||
import org.eclipse.jgit.lib.ObjectStream;
 | 
			
		||||
import org.eclipse.jgit.notes.Note;
 | 
			
		||||
import org.eclipse.jgit.notes.NoteMerger;
 | 
			
		||||
import org.eclipse.jgit.util.io.UnionInputStream;
 | 
			
		||||
@@ -67,12 +68,13 @@ class ReviewNoteMerger implements NoteMerger {
 | 
			
		||||
    ObjectLoader lo = reader.open(ours.getData());
 | 
			
		||||
    byte[] sep = new byte[] {'\n'};
 | 
			
		||||
    ObjectLoader lt = reader.open(theirs.getData());
 | 
			
		||||
    UnionInputStream union = new UnionInputStream(
 | 
			
		||||
        lo.openStream(),
 | 
			
		||||
        new ByteArrayInputStream(sep),
 | 
			
		||||
        lt.openStream());
 | 
			
		||||
    ObjectId noteData = inserter.insert(Constants.OBJ_BLOB,
 | 
			
		||||
        lo.getSize() + sep.length + lt.getSize(), union);
 | 
			
		||||
    return new Note(ours, noteData);
 | 
			
		||||
    try (ObjectStream os = lo.openStream();
 | 
			
		||||
        ByteArrayInputStream b = new ByteArrayInputStream(sep);
 | 
			
		||||
        ObjectStream ts = lt.openStream();
 | 
			
		||||
        UnionInputStream union = new UnionInputStream(os, b, ts)) {
 | 
			
		||||
      ObjectId noteData = inserter.insert(Constants.OBJ_BLOB,
 | 
			
		||||
          lo.getSize() + sep.length + lt.getSize(), union);
 | 
			
		||||
      return new Note(ours, noteData);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user