SourceForge.net Logo
Main Overview Wiki Issues Forum Build Fisheye
Issue Details (XML | Word | Printable)

Key: CMP-741
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Shay Banon
Reporter: Teon Metselaar
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Compass

CollectionResourceWrapper.computeProperty might return null causing a NullPointerException in getValue and getObject

Created: 16/Oct/08 04:42 AM   Updated: 16/Oct/08 01:22 PM
Component/s: Compass::Core
Affects Version/s: 2.1.0 M4
Fix Version/s: 2.1.0 RC


 Description  « Hide
The methods getValue() and getObject() in org.compass.core.converter.mapping.CollectionResourceWrapper return the StringValue or Objectvalue of the result of the private method computeProperty without checking for a null-result.
This causes a NullPointerException which is hard to trace.
I would suggest throwing an Exception which is a bit more to the point.

 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Shay Banon added a comment - 16/Oct/08 05:19 AM
Can you post a scenario and a stack trace of when this happens?

Teon Metselaar added a comment - 16/Oct/08 05:41 AM
I have made a custom converter in which I try to get a value for a field named "postcode" of the object I am trying to unmarshall:
resource.getValue(context.getPropertyNamingStrategy().buildPath(mapping.getPath(), "postcode").getPath()

This field should be filled by AdresConverter.marshall(), but it might happen that it has no value at all due to unexpected content.
The stack trace is as follows:

2008-10-16 12:30:05,150 ERROR [STDERR] java.lang.NullPointerException
2008-10-16 12:30:05,151 ERROR [STDERR] at org.compass.core.converter.mapping.CollectionResourceWrapper.getValue(CollectionResourceWrapper.java:59)
2008-10-16 12:30:05,151 ERROR [STDERR] at nl.gids.core.util.compassconverters.AdresConverter.unmarshall(AdresConverter.java:55)
2008-10-16 12:30:05,151 ERROR [STDERR] at org.compass.core.converter.mapping.osem.ClassMappingConverter.unmarshall(ClassMappingConverter.java:303)
2008-10-16 12:30:05,151 ERROR [STDERR] at org.compass.core.converter.mapping.osem.ComponentMappingConverter.doUnmarshall(ComponentMappingConverter.java:37)
2008-10-16 12:30:05,151 ERROR [STDERR] at org.compass.core.converter.mapping.osem.AbstractRefAliasMappingConverter.unmarshall(AbstractRefAliasMappingConverter.java:103)
2008-10-16 12:30:05,151 ERROR [STDERR] at org.compass.core.converter.mapping.osem.AbstractCollectionMappingConverter.unmarshall(AbstractCollectionMappingConverter.java:144)
2008-10-16 12:30:05,151 ERROR [STDERR] at org.compass.core.converter.mapping.osem.ClassMappingConverter.unmarshall(ClassMappingConverter.java:303)
2008-10-16 12:30:05,151 ERROR [STDERR] at org.compass.core.marshall.DefaultMarshallingStrategy.unmarshall(DefaultMarshallingStrategy.java:167)
2008-10-16 12:30:05,151 ERROR [STDERR] at org.compass.core.marshall.DefaultMarshallingStrategy.unmarshall(DefaultMarshallingStrategy.java:159)
2008-10-16 12:30:05,151 ERROR [STDERR] at org.compass.core.impl.DefaultCompassSession.getByResource(DefaultCompassSession.java:250)
2008-10-16 12:30:05,151 ERROR [STDERR] at org.compass.core.impl.DefaultCompassSession.getByResource(DefaultCompassSession.java:238)
2008-10-16 12:30:05,151 ERROR [STDERR] at org.compass.core.impl.DefaultCompassDetachedHits.<init>(DefaultCompassDetachedHits.java:82)
2008-10-16 12:30:05,151 ERROR [STDERR] at org.compass.core.impl.DefaultCompassHits.detach(DefaultCompassHits.java:108)
2008-10-16 12:30:05,151 ERROR [STDERR] at nl.gids.core.dao.search.impl.ZoekDAOImpl$2.doInCompass(ZoekDAOImpl.java:198)
2008-10-16 12:30:05,151 ERROR [STDERR] at nl.gids.core.dao.search.impl.ZoekDAOImpl$2.doInCompass(ZoekDAOImpl.java:1)
2008-10-16 12:30:05,151 ERROR [STDERR] at org.compass.core.CompassTemplate.execute(CompassTemplate.java:130)
2008-10-16 12:30:05,151 ERROR [STDERR] at org.compass.core.CompassTemplate.execute(CompassTemplate.java:112)

I hope this information is sufficient...


Shay Banon added a comment - 16/Oct/08 01:22 PM
I actually fixed that to return null in this case, since I think it is more correct to return null (similar to the fact that getProperty returns null).