From 1728d1d760154afafa99706b5169c9656d40a428 Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Sat, 4 Apr 2015 00:38:39 +0200 Subject: [PATCH] Use try-with-resource to close resources in ObjectDatabase Change-Id: Ib410bf0d3c300c25b615bb6a51488b3d88aeb3bd Signed-off-by: Matthias Sohn --- .../src/org/eclipse/jgit/lib/ObjectDatabase.java | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectDatabase.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectDatabase.java index 0cc51d1a5..2abd6dae6 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectDatabase.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectDatabase.java @@ -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(); } }