Browse Source

Merge "Use try-with-resource to close resources in BundleFetchConnection"

stable-4.1
Shawn Pearce 10 years ago committed by Gerrit Code Review @ Eclipse.org
parent
commit
32cc3c3096
  1. 10
      org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleFetchConnection.java

10
org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleFetchConnection.java

@ -183,16 +183,13 @@ class BundleFetchConnection extends BaseFetchConnection {
throws TransportException {
verifyPrerequisites();
try {
ObjectInserter ins = transport.local.newObjectInserter();
try {
try (ObjectInserter ins = transport.local.newObjectInserter()) {
PackParser parser = ins.newPackParser(bin);
parser.setAllowThin(true);
parser.setObjectChecker(transport.getObjectChecker());
parser.setLockMessage(lockMessage);
packLock = parser.parse(NullProgressMonitor.INSTANCE);
ins.flush();
} finally {
ins.release();
}
} catch (IOException err) {
close();
@ -217,8 +214,7 @@ class BundleFetchConnection extends BaseFetchConnection {
if (prereqs.isEmpty())
return;
final RevWalk rw = new RevWalk(transport.local);
try {
try (final RevWalk rw = new RevWalk(transport.local)) {
final RevFlag PREREQ = rw.newFlag("PREREQ"); //$NON-NLS-1$
final RevFlag SEEN = rw.newFlag("SEEN"); //$NON-NLS-1$
@ -281,8 +277,6 @@ class BundleFetchConnection extends BaseFetchConnection {
throw new MissingBundlePrerequisiteException(transport.uri,
missing);
}
} finally {
rw.release();
}
}

Loading…
Cancel
Save