lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Satuluri, Venu_Madhav" <>
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

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. 



To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message