LUCENE-1246: check for null sub queries so that BooleanQuery.toString does not throw NullPointerException.

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@722897 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Robert Miller 2008-12-03 14:15:22 +00:00
parent cfef10bb9d
commit 139f71599e
1 changed files with 11 additions and 6 deletions

View File

@ -424,12 +424,17 @@ public class BooleanQuery extends Query {
buffer.append("+");
Query subQuery = c.getQuery();
if (subQuery != null) {
if (subQuery instanceof BooleanQuery) { // wrap sub-bools in parens
buffer.append("(");
buffer.append(c.getQuery().toString(field));
buffer.append(subQuery.toString(field));
buffer.append(")");
} else
buffer.append(c.getQuery().toString(field));
} else {
buffer.append(subQuery.toString(field));
}
} else {
buffer.append("null");
}
if (i != clauses.size()-1)
buffer.append(" ");