You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by kw...@apache.org on 2022/07/18 14:26:06 UTC
[jackrabbit-oak] 01/01: OAK-9846: Emit origin for each checker report
This is an automated email from the ASF dual-hosted git repository.
kwin pushed a commit to branch feature/emit-checker-in-errorholder
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
commit 6b457993400adc2e07142c4d16f982c9d0a5cee9
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Mon Jul 18 16:25:59 2022 +0200
OAK-9846: Emit origin for each checker report
---
.../jackrabbit/oak/composite/checks/ErrorHolder.java | 10 +++++-----
.../composite/checks/NamespacePrefixNodestoreChecker.java | 2 +-
.../checks/NodeTypeDefinitionNodeStoreChecker.java | 4 ++--
.../composite/checks/NodeTypeMountedNodeStoreChecker.java | 2 +-
.../oak/composite/checks/UniqueIndexNodeStoreChecker.java | 14 ++++++++------
5 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/checks/ErrorHolder.java b/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/checks/ErrorHolder.java
index 2e4a5460f1..51b717e610 100644
--- a/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/checks/ErrorHolder.java
+++ b/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/checks/ErrorHolder.java
@@ -27,16 +27,16 @@ class ErrorHolder {
private static final int FAIL_IMMEDIATELY_THRESHOLD = 100;
private final List<String> errors = new ArrayList<>();
- public void report(MountedNodeStore mountedStore, String path, String error) {
- errors.add(String.format("For NodeStore mount %s, path %s, encountered the following problem: '%s'", mountedStore.getMount().getName(), path, error));
+ public void report(MountedNodeStore mountedStore, String path, String error, MountedNodeStoreChecker<?> checker) {
+ errors.add(String.format("For NodeStore mount %s, path %s, encountered the following problem: '%s' (via checker %s)", mountedStore.getMount().getName(), path, error, checker));
if ( errors.size() == FAIL_IMMEDIATELY_THRESHOLD ) {
end();
}
}
- public void report(MountedNodeStore firstNS, String firstPath, MountedNodeStore secondNS, String secondPath, String value, String error) {
- errors.add(String.format("For NodeStore mount %s, path %s, and NodeStore mount %s, path %s, encountered the following clash for value %s: '%s'",
- firstNS.getMount().getName(), firstPath, secondNS.getMount().getName(), secondPath, value, error));
+ public void report(MountedNodeStore firstNS, String firstPath, MountedNodeStore secondNS, String secondPath, String value, String error, MountedNodeStoreChecker<?> checker) {
+ errors.add(String.format("For NodeStore mount %s, path %s, and NodeStore mount %s, path %s, encountered the following clash for value %s: '%s' (via checker %s)",
+ firstNS.getMount().getName(), firstPath, secondNS.getMount().getName(), secondPath, value, error, checker));
if ( errors.size() == FAIL_IMMEDIATELY_THRESHOLD ) {
end();
}
diff --git a/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/checks/NamespacePrefixNodestoreChecker.java b/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/checks/NamespacePrefixNodestoreChecker.java
index 15330eb8e5..dff2fa21ae 100644
--- a/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/checks/NamespacePrefixNodestoreChecker.java
+++ b/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/checks/NamespacePrefixNodestoreChecker.java
@@ -67,7 +67,7 @@ public class NamespacePrefixNodestoreChecker implements MountedNodeStoreChecker<
String prefix = getPrefix(name);
if ( prefix != null && !context.validPrefixes.contains(prefix) ) {
- errorHolder.report(mountedStore, path, "invalid namespace prefix " + prefix + " , expected one of " + context.validPrefixes);
+ errorHolder.report(mountedStore, path, "invalid namespace prefix " + prefix + " , expected one of " + context.validPrefixes, this);
}
}
diff --git a/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/checks/NodeTypeDefinitionNodeStoreChecker.java b/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/checks/NodeTypeDefinitionNodeStoreChecker.java
index bb07783721..9803e5cb82 100644
--- a/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/checks/NodeTypeDefinitionNodeStoreChecker.java
+++ b/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/checks/NodeTypeDefinitionNodeStoreChecker.java
@@ -67,7 +67,7 @@ public class NodeTypeDefinitionNodeStoreChecker implements MountedNodeStoreCheck
@Override
public void onConstraintViolation(String path, List<String> typeNames, int code, String message)
throws CommitFailedException {
- errorHolder.report(mountedStore, path, message);
+ errorHolder.report(mountedStore, path, message, NodeTypeDefinitionNodeStoreChecker.this);
}
};
@@ -90,7 +90,7 @@ public class NodeTypeDefinitionNodeStoreChecker implements MountedNodeStoreCheck
EditorDiff.process(editor, MISSING_NODE, root);
} catch (CommitFailedException e) {
- errorHolder.report(mountedStore, "/", "Unexpected error : " + e.getMessage());
+ errorHolder.report(mountedStore, "/", "Unexpected error : " + e.getMessage(), this);
}
diff --git a/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/checks/NodeTypeMountedNodeStoreChecker.java b/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/checks/NodeTypeMountedNodeStoreChecker.java
index a30dca9309..004f9f40a8 100644
--- a/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/checks/NodeTypeMountedNodeStoreChecker.java
+++ b/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/checks/NodeTypeMountedNodeStoreChecker.java
@@ -92,7 +92,7 @@ public class NodeTypeMountedNodeStoreChecker implements
if ( context.getTypeManager().isNodeType(tree, invalidNodeType) &&
!isExcluded(mountedStore, tree, context) ) {
- errorHolder.report(mountedStore, tree.getPath(), errorLabel);
+ errorHolder.report(mountedStore, tree.getPath(), errorLabel, this);
}
return true;
diff --git a/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/checks/UniqueIndexNodeStoreChecker.java b/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/checks/UniqueIndexNodeStoreChecker.java
index 951dff1b4d..3ac1a800bf 100644
--- a/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/checks/UniqueIndexNodeStoreChecker.java
+++ b/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/checks/UniqueIndexNodeStoreChecker.java
@@ -78,7 +78,7 @@ public class UniqueIndexNodeStoreChecker implements MountedNodeStoreChecker<Uniq
for ( ChildNodeEntry indexDef : indexDefs.getChildNodeEntries() ) {
if ( indexDef.getNodeState().hasProperty(UNIQUE_PROPERTY_NAME) &&
indexDef.getNodeState().getBoolean(UNIQUE_PROPERTY_NAME) ) {
- ctx.add(indexDef, mip.getDefaultMount(), indexDefs);
+ ctx.add(indexDef, mip.getDefaultMount(), indexDefs, this);
ctx.track(new MountedNodeStore(mip.getDefaultMount() , globalStore));
}
}
@@ -102,7 +102,7 @@ public class UniqueIndexNodeStoreChecker implements MountedNodeStoreChecker<Uniq
NodeState mountIndexDef = indexDef.getNodeState().getChildNode(mountIndexDefName);
if ( mountIndexDef.exists() ) {
- context.add(indexDef, mountedStore.getMount(), indexDefs);
+ context.add(indexDef, mountedStore.getMount(), indexDefs, this);
}
}
}
@@ -126,11 +126,11 @@ public class UniqueIndexNodeStoreChecker implements MountedNodeStoreChecker<Uniq
mountedNodeStoresByName.put(mountedNodeStore.getMount().getName(), mountedNodeStore);
}
- public void add(ChildNodeEntry rootIndexDef, Mount mount, NodeState indexDef) {
+ public void add(ChildNodeEntry rootIndexDef, Mount mount, NodeState indexDef, UniqueIndexNodeStoreChecker checker) {
IndexCombination combination = combinations.get(rootIndexDef.getName());
if ( combination == null ) {
- combination = new IndexCombination(rootIndexDef);
+ combination = new IndexCombination(rootIndexDef, checker);
combinations.put(rootIndexDef.getName(), combination);
}
@@ -151,12 +151,14 @@ public class UniqueIndexNodeStoreChecker implements MountedNodeStoreChecker<Uniq
static class IndexCombination {
private final ChildNodeEntry rootIndexDef;
+ private final UniqueIndexNodeStoreChecker checker;
private final Map<Mount, NodeState> indexEntries = Maps.newHashMap();
private final List<Mount[]> checked = new ArrayList<>();
// bounded as the ErrorHolder has a reasonable limit of entries before it fails immediately
private final Set<String> reportedConflictingValues = new HashSet<>();
- IndexCombination(ChildNodeEntry rootIndexDef) {
+ IndexCombination(ChildNodeEntry rootIndexDef, UniqueIndexNodeStoreChecker checker) {
+ this.checker = checker;
this.rootIndexDef = rootIndexDef;
}
@@ -227,7 +229,7 @@ public class UniqueIndexNodeStoreChecker implements MountedNodeStoreChecker<Uniq
IndexEntry hit2 = result.get();
if ( reportedConflictingValues.add(hit.getPropertyValue())) {
errorHolder.report(wrapper.nodeStore, hit.getPath(), wrapper2.nodeStore, hit2.getPath(),
- hit.getPropertyValue(), "duplicate unique index entry");
+ hit.getPropertyValue(), "duplicate unique index entry", checker);
}
}
}