]> source.dussan.org Git - jgit.git/commitdiff
Use try-with-resource to close resources in ObjectDatabase 77/45277/1
authorMatthias Sohn <matthias.sohn@sap.com>
Fri, 3 Apr 2015 22:38:39 +0000 (00:38 +0200)
committerMatthias Sohn <matthias.sohn@sap.com>
Fri, 3 Apr 2015 22:38:39 +0000 (00:38 +0200)
Change-Id: Ib410bf0d3c300c25b615bb6a51488b3d88aeb3bd
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectDatabase.java

index 0cc51d1a52d9da2ba50890dd59412ee6ba52769e..2abd6dae61b4fa57fc4429f91cd81d09b62122b1 100644 (file)
@@ -120,11 +120,8 @@ public abstract class ObjectDatabase {
         *             the object store cannot be accessed.
         */
        public boolean has(final AnyObjectId objectId) throws IOException {
-               final ObjectReader or = newReader();
-               try {
+               try (final ObjectReader or = newReader()) {
                        return or.has(objectId);
-               } finally {
-                       or.release();
                }
        }
 
@@ -172,11 +169,8 @@ public abstract class ObjectDatabase {
        public ObjectLoader open(AnyObjectId objectId, int typeHint)
                        throws MissingObjectException, IncorrectObjectTypeException,
                        IOException {
-               final ObjectReader or = newReader();
-               try {
+               try (final ObjectReader or = newReader()) {
                        return or.open(objectId, typeHint);
-               } finally {
-                       or.release();
                }
        }