Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Keppler2019-06-20 04:08:12 -0400
committerMichael Keppler2019-06-24 08:26:45 -0400
commit2a6d24376833d10036f81a79d8423be4a5c59b3c (patch)
treed799f84ee9901d4085529eb45b84a86d2a39ab96 /org.eclipse.egit.ui/src/org/eclipse
parent319caf2e4b81c538aa2ee759a516d3157d6a3ec3 (diff)
downloadegit-2a6d24376833d10036f81a79d8423be4a5c59b3c.tar.gz
egit-2a6d24376833d10036f81a79d8423be4a5c59b3c.tar.xz
egit-2a6d24376833d10036f81a79d8423be4a5c59b3c.zip
Fix NPE in RepositoriesViewPropertyTester
There can be a race condition when first getting the list of all child paths and then iterating the paths to get the ref again, since the ref can have been deleted in the meantime by another thread. Avoid the race condition by using just a single interaction with the ref database. Bug:548434 Change-Id: Ie665d4b1c7c49668550a5f75341695b1a24c52a2 Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
Diffstat (limited to 'org.eclipse.egit.ui/src/org/eclipse')
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/BranchHierarchyNode.java12
1 files changed, 4 insertions, 8 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/BranchHierarchyNode.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/BranchHierarchyNode.java
index 5acd9e1a0..ab4dd6780 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/BranchHierarchyNode.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/BranchHierarchyNode.java
@@ -16,6 +16,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import java.util.stream.Collectors;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
@@ -89,14 +90,9 @@ public class BranchHierarchyNode extends RepositoryTreeNode<IPath> {
* @throws IOException
*/
public List<Ref> getChildRefsRecursive() throws IOException {
- List<Ref> childRefs = new ArrayList<>();
- for (IPath myPath : getPathList()) {
- if (getObject().isPrefixOf(myPath)) {
- Ref ref = getRepository().exactRef(myPath.toPortableString());
- childRefs.add(ref);
- }
- }
- return childRefs;
+ return getRepository().getRefDatabase()
+ .getRefsByPrefix(getObject().toPortableString()).stream()
+ .filter(ref -> !ref.isSymbolic()).collect(Collectors.toList());
}
private List<IPath> getPathList() throws IOException {

Back to the top