Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Isolate LazyNodeset lock from evaluated object #1404

Merged
merged 1 commit into from
Apr 19, 2024
Merged
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
11 changes: 5 additions & 6 deletions src/main/java/org/javarosa/xpath/XPathLazyNodeset.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@
*/
public class XPathLazyNodeset extends XPathNodeset {

//Since we're using this as a lock, we need to be very careful to ensure that each
//nodeset gets its own new object.
private Boolean evaluated = Boolean.valueOf(false);
private Object evalLock = new Object();
private boolean evaluated = false;
private final TreeReference unExpandedRef;

/**
Expand All @@ -43,7 +42,7 @@ public XPathLazyNodeset(TreeReference unExpandedRef, DataInstance instance, Eval


private void performEvaluation() {
synchronized (evaluated) {
synchronized (evalLock) {
if (evaluated) {
return;
}
Expand All @@ -57,7 +56,7 @@ private void performEvaluation() {
}
}
this.setReferences(nodes);
evaluated = Boolean.valueOf(true);
evaluated = true;
}
}

Expand All @@ -69,7 +68,7 @@ private void performEvaluation() {
*/
@Override
public Object unpack() {
synchronized (evaluated) {
synchronized (evalLock) {
if (evaluated) {
return super.unpack();
}
Expand Down
Loading