Browse Source

Release ObjectInserter in merge() not mergeImpl()

By doing the release at the higher level class, we can ensure
the release occurs if the inserter was allocated, even if the
implementation forgets to do this.  Since the higher level class
is what allocated it, it makes sense to have it also do the release.

Change-Id: Id617b2db864c3208ed68cba4eda80e51612359ad
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
stable-0.9
Shawn O. Pearce 15 years ago
parent
commit
b40f02eb1a
  1. 7
      org.eclipse.jgit/src/org/eclipse/jgit/merge/Merger.java
  2. 11
      org.eclipse.jgit/src/org/eclipse/jgit/merge/StrategySimpleTwoWayInCore.java

7
org.eclipse.jgit/src/org/eclipse/jgit/merge/Merger.java

@ -148,7 +148,12 @@ public abstract class Merger {
for (int i = 0; i < sourceObjects.length; i++)
sourceTrees[i] = walk.parseTree(sourceObjects[i]);
return mergeImpl();
try {
return mergeImpl();
} finally {
if (inserter != null)
inserter.release();
}
}
/**

11
org.eclipse.jgit/src/org/eclipse/jgit/merge/StrategySimpleTwoWayInCore.java

@ -154,15 +154,8 @@ public class StrategySimpleTwoWayInCore extends ThreeWayMergeStrategy {
return false;
try {
ObjectInserter odi = getObjectInserter();
try {
resultTree = cache.writeTree(odi);
odi.flush();
} finally {
// We don't know if our caller will release the
// inserter, so make sure we do it ourselves.
//
odi.release();
}
resultTree = cache.writeTree(odi);
odi.flush();
return true;
} catch (UnmergedPathException upe) {
resultTree = null;

Loading…
Cancel
Save