I ran across this problem when using Hibernate Search to build an index for pre-existing data. Our data contains a Boolean field
recommended that, in our database, can contain
null values. When Search attempted to index documents with
null Boolean values, it crashed, showing a
NullPointerException at BooleanBridge.java@20. When I looked through the source, it appears that the code reads:
Code:
Boolean b = (Boolean) object;
return b.toString();
As such, a
null Boolean value was crashing on the
toString() method. The fix that I implemented was changing
Code:
return b.toString();
to
Code:
return (b == null) ? null : b.toString();
This issue does not appear to happen in any of the other Bridges, they already seem to handle
null values. I wanted to verify that this is indeed a bug before submitting the issue to JIRA.
Thank you.