Fix resource leak when changeMerge.test is true

The changeMerge feature leaks a Repository handle every time it
executes a test. For our installation of Gerrit, this leaks some
file handles, which can cause the JVM to run out of descriptors
and/or run out of native memory that back those objects.

A Repository, like a ReviewDb, must always be closed by the
caller after it is no longer required. A quick scan through
other call sites indicates other uses are in fact closing,
this was the only bug found.

Change-Id: If3fac76e82478a5bf32085d704842d88926ddd97
This commit is contained in:
Shawn O. Pearce
2012-06-21 10:04:55 -07:00
parent 618456122e
commit b1003300c7

View File

@@ -249,10 +249,12 @@ public class MergeOp {
log.error("Test merge attempt for change: " + change.getId()
+ " failed", e);
} finally {
if (repo != null) {
repo.close();
}
if (db != null) {
db.close();
}
db = null;
}
}
@@ -292,8 +294,9 @@ public class MergeOp {
if (repo != null) {
repo.close();
}
if (db != null) {
db.close();
db = null;
}
}
}