The method BooleanQuery.add( Query q, BooleanClause.Occur o) accepts
Query objects that are null for its first parameter i.e. it doesn't
throw any exception. However, when we try to get the string form of the
same BooleanQuery object, it throws a NullPointerException from within
the toString() code of BooleanQuery.

Try this code for example: 
          BooleanQuery bq = new BooleanQuery();
        bq.add(null, BooleanClause.Occur.SHOULD);
        System.out.println( bq.toString() );

It throws the following exception:
Exception in thread "main" java.lang.NullPointerException
        at
org.apache.lucene.search.BooleanQuery.toString(BooleanQuery.java:421)
        at org.apache.lucene.search.Query.toString(Query.java:79)
        at
deshaw.reccms.search.LuceneGenerator.main(LuceneGenerator.java:751)

It seems to me that an IllegalArgumentException or some other
RuntimeException should be thrown at line no. 2, from the
BooleanQuery.add() method, because clearly BooleanQuery objects don't
handle null Queries. 

Thoughts?

Thanks,
Venu

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to