]> source.dussan.org Git - jgit.git/commitdiff
Use try-with-resource to close resources in BundleFetchConnection 98/45098/1
authorMatthias Sohn <matthias.sohn@sap.com>
Wed, 1 Apr 2015 23:24:05 +0000 (01:24 +0200)
committerMatthias Sohn <matthias.sohn@sap.com>
Wed, 1 Apr 2015 23:24:05 +0000 (01:24 +0200)
Change-Id: Id79c01133b835e278d5b494b5bc5972d7aeed9a9
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleFetchConnection.java

index e3cfd22adba3d8028b79776b530bf50c9d8555db..e53c04b535e5c1e651f4994fa87c8c7c2d689854 100644 (file)
@@ -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();
                }
        }