Browse Source

Use try-with-resource to close resources in ObjectDatabase

Change-Id: Ib410bf0d3c300c25b615bb6a51488b3d88aeb3bd
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
tags/v4.0.0.201505050340-m2
Matthias Sohn 9 years ago
parent
commit
1728d1d760
1 changed files with 2 additions and 8 deletions
  1. 2
    8
      org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectDatabase.java

+ 2
- 8
org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectDatabase.java View File

* 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 {
try (final ObjectReader or = newReader()) {
return or.has(objectId); return or.has(objectId);
} finally {
or.release();
} }
} }


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 {
try (final ObjectReader or = newReader()) {
return or.open(objectId, typeHint); return or.open(objectId, typeHint);
} finally {
or.release();
} }
} }



Loading…
Cancel
Save