You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Trejkaz (JIRA)" <ji...@apache.org> on 2014/05/16 13:19:12 UTC

[jira] [Created] (LUCENE-5676) QueryNodeImpl is too mutable

Trejkaz created LUCENE-5676:
-------------------------------

             Summary: QueryNodeImpl is too mutable
                 Key: LUCENE-5676
                 URL: https://issues.apache.org/jira/browse/LUCENE-5676
             Project: Lucene - Core
          Issue Type: Improvement
          Components: modules/queryparser
            Reporter: Trejkaz


We use query nodes both during parsing and as a method of building queries. Somehow a bug has crept into our system where a QueryNode somehow gets mutated to have a parent when the node we created didn't originally have a parent. Some processor in our pipeline treats nodes differently based on the parent, which makes it a very hard to find bug.

It would be very helpful if there were a method like freeze() which would make the instance immutable from thereon, something like the following:

{code}
private volatile boolean frozen;

public final boolean isFrozen() {
    return frozen;
};

protected void aboutToMakeChanges() {
    if (isFrozen()) {
        throw new IllegalStateException("This object is frozen");
    }
}

public A freeze() {
    frozen = true;
    return this;
}

// ...

private void setParent(QueryNode parent) {
    aboutToMakeChanges();
    // existing code
}
{code}




--
This message was sent by Atlassian JIRA
(v6.2#6252)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org