Browse Source

Use try-with-resource to close resources in ObjectDatabase

Change-Id: Ib410bf0d3c300c25b615bb6a51488b3d88aeb3bd
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
stable-4.1
Matthias Sohn 10 years ago
parent
commit
1728d1d760
  1. 10
      org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectDatabase.java

10
org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectDatabase.java

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

Loading…
Cancel
Save