code.onehippo.org is currently readonly. We are migrating to code.bloomreach.com, please continue working there on Monday 14/12. See: https://docs.bloomreach.com/display/engineering/GitLab

Commit 7c073da1 authored by Jeroen Hoffman's avatar Jeroen Hoffman

REPO-1695 avoid NPE in ServicingSearchIndex#updateNodes by simple null checks after .next() calls

parent 6856a81e
/*
* Copyright 2008-2016 Hippo B.V. (http://www.onehippo.com)
* Copyright 2008-2017 Hippo B.V. (http://www.onehippo.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -404,15 +404,20 @@ public class ServicingSearchIndex extends SearchIndex implements HippoQueryHandl
final Set<NodeId> augmentedRemove = new HashSet<>();
while (remove.hasNext()) {
augmentedRemove.add(remove.next());
final NodeId nodeId = remove.next();
if (nodeId != null) {
augmentedRemove.add(nodeId);
}
}
// NodeState does not implement equals hence we need NodeId
final Map<NodeId, NodeState> augmentedAdd = new HashMap<>();
while (add.hasNext()) {
final NodeState nodeState = add.next();
// since NodeState does not have hashcode/equals impls, we need to use NodeId for equals in Map
augmentedAdd.put(nodeState.getNodeId(), nodeState);
if (nodeState != null) {
// since NodeState does not have hashcode/equals impls, we need to use NodeId for equals in Map
augmentedAdd.put(nodeState.getNodeId(), nodeState);
}
}
appendDocumentsThatHaveChangedChildNodesOrChangedHandles(augmentedRemove, augmentedAdd);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment