NPE in BeanReferenceCollectionConverterImpl on update on empty collection -------------------------------------------------------------------------
Key: JCR-1470 URL: https://issues.apache.org/jira/browse/JCR-1470 Project: Jackrabbit Issue Type: Bug Components: observation Affects Versions: 1.5 Environment: mac os leopard, java5 Reporter: Stephane Landelle use case : in the same transaction : *) retrieve an object that has a collection of references, yet empty *) add an element in the collection *) update the object consequence : org.apache.jackrabbit.ocm.exception.ObjectContentManagerException: Cannot insert collection field : authors of class com.weka.content.api.model.Folder; nested exception is java.lang.NullPointerException: null java.lang.NullPointerException at org.apache.jackrabbit.ocm.manager.collectionconverter.impl.ManageableArrayList$$EnhancerByCGLIB$$8f15dde4.getSize(<generated>) at org.apache.jackrabbit.ocm.manager.collectionconverter.impl.BeanReferenceCollectionConverterImpl.addUuidProperties(BeanReferenceCollectionConverterImpl.java:154) at org.apache.jackrabbit.ocm.manager.collectionconverter.impl.BeanReferenceCollectionConverterImpl.doUpdateCollection(BeanReferenceCollectionConverterImpl.java:101) The failing line is in addUuidProperties : Value[] values = new Value[collection.getSize()]; It seems the CGlib enhanced collection fails and needs to be initialized before. For example, in doUpdateCollection, if I code : // Delete existing values if (parentNode.hasProperty(jcrName)) { parentNode.setProperty(jcrName, (Value[]) null); } if (collection != null) { collection.getSize(); <<<<<< } I get a NPE on collection.getSize(); but if I code : if (collection != null) { collection.getSize(); } // Delete existing values if (parentNode.hasProperty(jcrName)) { parentNode.setProperty(jcrName, (Value[]) null); } everything runs fine?! -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.