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 th...@apache.org on 2019/02/08 10:47:36 UTC
svn commit: r1853206 -
/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java
Author: thomasm
Date: Fri Feb 8 10:47:35 2019
New Revision: 1853206
URL: http://svn.apache.org/viewvc?rev=1853206&view=rev
Log:
OAK-7997 : Adding restrictions to ACLs yields empty results for queries in Jackrabbit Oak (rename and simplify a bit)
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java?rev=1853206&r1=1853205&r2=1853206&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SelectorImpl.java Fri Feb 8 10:47:35 2019
@@ -169,7 +169,7 @@ public class SelectorImpl extends Source
private String planIndexName;
private TimerStats timerDuration;
- private LastTree lastTree;
+ private CachedTree cachedTree;
public SelectorImpl(NodeTypeInfo nodeTypeInfo, String selectorName) {
this.nodeTypeInfo = checkNotNull(nodeTypeInfo);
@@ -528,7 +528,7 @@ public class SelectorImpl extends Source
// where [a].[jcr:path] = $path"
// because not checking would reveal existence
// of the child node
- if (!getLastTree(currentRow.getPath()).exists()) {
+ if (!getCachedTree(currentRow.getPath()).exists()) {
continue;
}
}
@@ -565,13 +565,13 @@ public class SelectorImpl extends Source
}
private boolean evaluateTypeMatch() {
- LastTree lt = getLastTree(currentRow.getPath());
- if (!lt.exists()) {
+ CachedTree ct = getCachedTree(currentRow.getPath());
+ if (!ct.exists()) {
return false;
}
- Tree t = lt.getTree();
- LazyValue<Tree> readOnly = lt.getReadOnlyTree();
+ Tree t = ct.getTree();
+ LazyValue<Tree> readOnly = ct.getReadOnlyTree();
String primaryTypeName = TreeUtil.getPrimaryTypeName(t, readOnly);
if (primaryTypeName != null && primaryTypes.contains(primaryTypeName)) {
return true;
@@ -611,7 +611,7 @@ public class SelectorImpl extends Source
@Nullable
Tree getTree(@NotNull String path) {
- return getLastTree(path).getTree();
+ return getCachedTree(path).getTree();
}
/**
@@ -621,11 +621,11 @@ public class SelectorImpl extends Source
* @return the tree, or null
*/
@NotNull
- private LastTree getLastTree(@NotNull String path) {
- if (lastTree == null || !lastTree.denotes(path)) {
- lastTree = new LastTree(path, query);
+ private CachedTree getCachedTree(@NotNull String path) {
+ if (cachedTree == null || !cachedTree.denotes(path)) {
+ cachedTree = new CachedTree(path, query);
}
- return lastTree;
+ return cachedTree;
}
/**
@@ -889,17 +889,23 @@ public class SelectorImpl extends Source
return new SelectorImpl(nodeTypeInfo, selectorName);
}
- private static final class LastTree {
+ private static final class CachedTree {
private final String path;
private final Tree tree;
private final ExecutionContext ctx;
- private LazyValue<Tree> readOnlyTree;
+ private final LazyValue<Tree> readOnlyTree;
- private LastTree(@NotNull String path, @NotNull QueryImpl query) {
+ private CachedTree(@NotNull String path, @NotNull QueryImpl query) {
this.path = path;
this.tree = query.getTree(path);
this.ctx = query.getExecutionContext();
+ this.readOnlyTree = new LazyValue<Tree>() {
+ @Override
+ protected Tree createValue() {
+ return new ImmutableRoot(ctx.getBaseState()).getTree(path);
+ }
+ };
}
private boolean denotes(@NotNull String path) {
@@ -917,14 +923,6 @@ public class SelectorImpl extends Source
@NotNull
private LazyValue<Tree> getReadOnlyTree() {
- if (readOnlyTree == null) {
- readOnlyTree = new LazyValue<Tree>() {
- @Override
- protected Tree createValue() {
- return new ImmutableRoot(ctx.getBaseState()).getTree(path);
- }
- };
- }
return readOnlyTree;
}
}