Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 345495 - Replacing IndirectContainer's ValueHolder can lead to a NullPointerException
Summary: Replacing IndirectContainer's ValueHolder can lead to a NullPointerException
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-11 16:04 EDT by David Minsky CLA
Modified: 2022-06-09 10:26 EDT (History)
0 users

See Also:


Attachments
Proposed fix, and testcase (16.66 KB, patch)
2011-05-11 18:10 EDT, David Minsky CLA
no flags Details | Diff
Proposed fix, and testcase (19.77 KB, patch)
2011-05-12 12:47 EDT, David Minsky CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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