瀏覽代碼

RefDirectory: Fire RefsChangedEvent on error, too

getRef and exactRef can produce recoverable exceptions --- for
example, a corrupt loose ref that cannot be parsed.  If readRef was
called and updated looseRefs in the process, RefsChangedEvent should
still be fired.

Noticed while improving the implementation of getRef.  This commit
only affects exactRef and getRef.  Other methods might be similarly
skipping firing RefsChangedEvent in their error handling code, and
this change does not fix them.

Change-Id: I0f460f6c8d9a585ad8453a4a47c1c77e24a1fb83
Signed-off-by: Jonathan Nieder <jrn@google.com>
tags/v5.3.0.201901161700-m1
Jonathan Nieder 8 年之前
父節點
當前提交
f46e223187
共有 1 個檔案被更改,包括 15 行新增11 行删除
  1. 15
    11
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java

+ 15
- 11
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java 查看文件

@@ -343,24 +343,28 @@ public class RefDirectory extends RefDatabase {
/** {@inheritDoc} */
@Override
public Ref exactRef(String name) throws IOException {
Ref ref = readAndResolve(name, getPackedRefs());
fireRefsChanged();
return ref;
try {
return readAndResolve(name, getPackedRefs());
} finally {
fireRefsChanged();
}
}

/** {@inheritDoc} */
@Override
public Ref getRef(String needle) throws IOException {
final RefList<Ref> packed = getPackedRefs();
Ref ref = null;
for (String prefix : SEARCH_PATH) {
ref = readAndResolve(prefix + needle, packed);
if (ref != null) {
break;
try {
RefList<Ref> packed = getPackedRefs();
for (String prefix : SEARCH_PATH) {
Ref ref = readAndResolve(prefix + needle, packed);
if (ref != null) {
return ref;
}
}
return null;
} finally {
fireRefsChanged();
}
fireRefsChanged();
return ref;
}

/** {@inheritDoc} */

Loading…
取消
儲存