Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ class SecureNodeBuilder implements NodeBuilder {
*/
private TreePermission rootPermission = null; // initialized lazily

private volatile boolean reevaluatePermissions = true;

/**
* Create the {@code SecureNodeBuilder} for the root node.
*
Expand Down Expand Up @@ -158,8 +160,7 @@ public boolean isReplaced(String name) {

public void baseChanged() {
Validate.checkState(parent == null);
treePermission = null; // trigger re-evaluation
rootPermission = null;
reevaluatePermissions = true;
}

@Override
Expand Down Expand Up @@ -350,8 +351,7 @@ public Blob createBlob(InputStream stream) throws IOException {
*/
@NotNull
private TreePermission getTreePermission() {
if (treePermission == null
|| rootPermission != rootBuilder.treePermission) {
if (isPermissionEvaluationNeeded()) {
NodeState base = builder.getBaseState();
String msg = "see OAK-11790 and OAK-11843";
if (parent == null) {
Expand All @@ -364,10 +364,18 @@ private TreePermission getTreePermission() {
treePermission = Objects.requireNonNull(parentTreePermission.getChildPermission(name, base), msg);
rootPermission = parent.rootPermission;
}
reevaluatePermissions = false;
}
return treePermission;
}

private boolean isPermissionEvaluationNeeded() {
if (rootPermission != rootBuilder.treePermission) {
reevaluatePermissions = true;
}
return reevaluatePermissions;
}

private static boolean isType(@Nullable PropertyState property, Type<?> type) {
Type<?> t = (property == null) ? null : property.getType();
return t == type;
Expand Down