From 139f71599e0e4e081b4b6fd1aa416e73ac31cbf7 Mon Sep 17 00:00:00 2001 From: Mark Robert Miller Date: Wed, 3 Dec 2008 14:15:22 +0000 Subject: [PATCH] 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 --- .../org/apache/lucene/search/BooleanQuery.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/java/org/apache/lucene/search/BooleanQuery.java b/src/java/org/apache/lucene/search/BooleanQuery.java index 4f2a5693907..0bf71ca7bb4 100644 --- a/src/java/org/apache/lucene/search/BooleanQuery.java +++ b/src/java/org/apache/lucene/search/BooleanQuery.java @@ -424,12 +424,17 @@ public class BooleanQuery extends Query { buffer.append("+"); Query subQuery = c.getQuery(); - if (subQuery instanceof BooleanQuery) { // wrap sub-bools in parens - buffer.append("("); - buffer.append(c.getQuery().toString(field)); - buffer.append(")"); - } else - buffer.append(c.getQuery().toString(field)); + if (subQuery != null) { + if (subQuery instanceof BooleanQuery) { // wrap sub-bools in parens + buffer.append("("); + buffer.append(subQuery.toString(field)); + buffer.append(")"); + } else { + buffer.append(subQuery.toString(field)); + } + } else { + buffer.append("null"); + } if (i != clauses.size()-1) buffer.append(" ");