From 2693d6075d771bc1503168653ed2ce91b703fb7d Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Sat, 4 Apr 2015 00:05:14 +0200 Subject: [PATCH] Use try-with-resource to close resources in FetchProcess Change-Id: If489d530ca39ae279c8da848f870b561c38eac3c Signed-off-by: Matthias Sohn --- .../src/org/eclipse/jgit/transport/FetchProcess.java | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchProcess.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchProcess.java index 52a9bab4b..d2902a35b 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchProcess.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchProcess.java @@ -196,8 +196,7 @@ else if (tagopt == TagOpt.FETCH_TAGS) .newBatchUpdate() .setAllowNonFastForwards(true) .setRefLogMessage("fetch", true); //$NON-NLS-1$ - final RevWalk walk = new RevWalk(transport.local); - try { + try (final RevWalk walk = new RevWalk(transport.local)) { if (monitor instanceof BatchingProgressMonitor) { ((BatchingProgressMonitor) monitor).setDelayStart( 250, TimeUnit.MILLISECONDS); @@ -226,8 +225,6 @@ else if (tagopt == TagOpt.FETCH_TAGS) throw new TransportException(MessageFormat.format( JGitText.get().failureUpdatingTrackingRef, getFirstFailedRefName(batch), err.getMessage()), err); - } finally { - walk.release(); } if (!fetchHeadUpdates.isEmpty()) { @@ -338,15 +335,12 @@ private void updateFETCH_HEAD(final FetchResult result) throws IOException { private boolean askForIsComplete() throws TransportException { try { - final ObjectWalk ow = new ObjectWalk(transport.local); - try { + try (final ObjectWalk ow = new ObjectWalk(transport.local)) { for (final ObjectId want : askFor.keySet()) ow.markStart(ow.parseAny(want)); for (final Ref ref : localRefs().values()) ow.markUninteresting(ow.parseAny(ref.getObjectId())); ow.checkConnectivity(); - } finally { - ow.release(); } return true; } catch (MissingObjectException e) {