Skip to content
This repository has been archived by the owner on Sep 21, 2022. It is now read-only.

Improve collection-setter-injector plugin to eagerly initialize collection properties #13

Open
glassfishrobot opened this issue Oct 14, 2008 · 10 comments

Comments

@glassfishrobot
Copy link
Contributor

If the List implementation is the default java.util.ArrayList, it will be lazily
initialized.
This can cause a problem when using the EqualsBuilder.reflectionEquals(obj, obj)
method, as implemented by commons-lang-plugin, if the expected object holds a
null for a collection property while the actual object holds an empty ArrayList
simply because the getter method has been called, which has a side effect.
Note that the lazy initialization is implemented for performance reason.

Environment

Operating System: All
Platform: All

Affected Versions

[current]

@glassfishrobot
Copy link
Contributor Author

Reported by ozgwei

@glassfishrobot
Copy link
Contributor Author

Was assigned to lexi

@glassfishrobot
Copy link
Contributor Author

ozgwei said:
Created an attachment (id=5)
eager initializing collection properties

@glassfishrobot
Copy link
Contributor Author

File: collection-setter-injector-patch.txt
Attached By: ozgwei

@glassfishrobot
Copy link
Contributor Author

ozgwei said:
Attached is a patch to allow users to optionally specifies whether eager
initialization of list properties are preferred.

Alex

@glassfishrobot
Copy link
Contributor Author

ozgwei said:
Created an attachment (id=6)
a newer patch with null check in setter method, overwriting the previous submitted patch

@glassfishrobot
Copy link
Contributor Author

File: collection-setter-injector-patch-20081015-1641.txt
Attached By: ozgwei

@glassfishrobot
Copy link
Contributor Author

ozgwei said:
When user specifies the option of eager initialization, the collection setter
methods generated will also check whether the parameter is null or not. If the
parameter is null, a newly created ArrayList will be assigned to the collection
property.

@glassfishrobot
Copy link
Contributor Author

lexi said:
The plugin was not ported after cvs->svn move, dead at the moment.

@glassfishrobot
Copy link
Contributor Author

This issue was imported from java.net JIRA JAXB2_COMMONS-13

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant