Browse Source

Merge "Use try-with-resource to close resources in ObjectDatabase"

stable-4.1
Shawn Pearce 10 years ago committed by Gerrit Code Review @ Eclipse.org
parent
commit
67568ee630
  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.
*/
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();
}
}

Loading…
Cancel
Save