lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Satuluri, Venu_Madhav" <Venu.Madhav.Satul...@deshaw.com>
Subject Possible improvement in BooleanQuery
Date Wed, 21 Jun 2006 15:48:17 GMT
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: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message