瀏覽代碼

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 年之前
父節點
當前提交
1728d1d760
共有 1 個檔案被更改,包括 2 行新增8 行删除
  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 查看文件

@@ -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…
取消
儲存