javaee / jaxb2-commons

JAXB Implementation project has been contributed to Eclipse Foundation. This repository is for legacy review only. Please refer to the Eclipse EE4J Metro project for the very latest
https://eclipse-ee4j.github.io/jaxb-ri/
Other
17 stars 15 forks source link

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

Open glassfishrobot opened 15 years ago

glassfishrobot commented 15 years ago

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 commented 15 years ago

Reported by ozgwei

glassfishrobot commented 15 years ago

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

glassfishrobot commented 15 years ago

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

Alex

glassfishrobot commented 15 years ago

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

glassfishrobot commented 15 years ago

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 commented 10 years ago

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

glassfishrobot commented 15 years ago

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

glassfishrobot commented 15 years ago

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

glassfishrobot commented 15 years ago

Was assigned to lexi

glassfishrobot commented 7 years ago

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