lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Trejkaz (JIRA)" <j...@apache.org>
Subject [jira] [Created] (LUCENE-5676) QueryNodeImpl is too mutable
Date Fri, 16 May 2014 11:19:12 GMT
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


Mime
View raw message