Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 345495

Summary: Replacing IndirectContainer's ValueHolder can lead to a NullPointerException
Product: z_Archived Reporter: David Minsky <david.minsky>
Component: EclipselinkAssignee: Nobody - feel free to take it <nobody>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Proposed fix, and testcase
none
Proposed fix, and testcase none

Description David Minsky CLA 2011-05-11 16:04:10 EDT
Caused by: java.lang.NullPointerException
at org.eclipse.persistence.indirection.IndirectSet.size(IndirectSet.java:501)

When an attribute is typed as Set or Map and mapped using transparent indirection (IndirectSet, IndirectMap), setting a default ValueHolder instance into the IndirectContainer's ValueHolder will return null when buildDelegate() is called internally to the IndirectSet/IndirectMap. If null is returned by buildDelegate, operations such as size() on the IndirectSet/Map will fail with a spurious NullPointerException.

This does not occur for IndirectList, as this situation is handled in buildDelegate() with a null check which returns a default List object on null instead of null itself.

The potential fix for this issue is to check for a null ValueHolder delegate within the buildDelegate methods of IndirectSet and IndirectMap. If null is detected, instantiate and return a "default" collection specific to the indirect container.
Comment 1 David Minsky CLA 2011-05-11 18:10:32 EDT
Created attachment 195443 [details]
Proposed fix, and testcase

- Main changes are to buildDelegate for IndirectSet and IndirectMap
- Removed unneeded "testing prototype" IndirectSet and changed test references to use the correct EL IndirectSet
- Added NullDelegateInValueHolderTest (for each container) to TransparentIndirectionModel
Comment 2 David Minsky CLA 2011-05-12 12:47:10 EDT
Created attachment 195513 [details]
Proposed fix, and testcase

Forgot to svn 'add' the actual testcase class. Corrected.
Comment 3 David Minsky CLA 2011-05-12 14:49:48 EDT
Checked in changes to trunk (2.3) at revision 9370
Reviewed: Gordon Yorke
Comment 4 David Minsky CLA 2011-05-24 15:21:09 EDT
Checked into 2.1 trunk at revision: 9444
Comment 5 David Minsky CLA 2011-05-24 16:38:55 EDT
Checked into 2.2 trunk at revision 9445
Comment 6 Eclipse Webmaster CLA 2022-06-09 10:16:50 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink
Comment 7 Eclipse Webmaster CLA 2022-06-09 10:26:17 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink