Open Tomas-Kraus opened 10 years ago
@glassfishrobot Commented Reported by killerchamb
@glassfishrobot Commented laune said: Consider; class A1
{ protected List
works, as does
class A2 {
//...
public void setList(List
{ this.list = list; }
//...
}
With class A as shown, the client must provide the implementation for List
Which, after all, would make a client write code like
a.setList( new ArrayList
{ ;a.setList( a.getList().add() ); }
because it isn't guaranteed that what you set is what you get; resulting in a markedly inefficient code.
It may be regrettable that JAXB'S behaviour has changed, but I wouldn't expect it to work with a class according to the pattern of class A.
@glassfishrobot Commented yaroska said: Hi @killerchamb,
Why do you think this is a bug?
In any case you can clone the collection after unmarshalling, right?
I'm going to close this as 'Not a bug'
@glassfishrobot Commented killerchamb said: Hi, and thank you for looking at this.
I agree that the new behaviour is not a bug, not more than the previous behaviour at least. It's just that it does not work in a few more cases than before, when the getter/setter methods of a class modify the data. When you can alter the source code of the serialized classes it is very easy to fix, when you cannot it blocks you.
I let you close the ticket, at least there will be a trace of the discussion.
@glassfishrobot Commented yaroska said: The only thing I can imagine is, that we can set already populated collection. I'll give a try.
Thanks for reporting.
@glassfishrobot Commented yaroska said: @me -> https://java.net/jira/browse/JAXB-948
@glassfishrobot Commented Was assigned to yaroska
@glassfishrobot Commented This issue was imported from java.net JIRA JAXB-1043
Recent versions of JAXB handle collection properties differently than before. An empty collection is created at the beginning, and set into the target bean, and then elements are added to the collection, without any interaction with the bean.
So if the bean for instance makes a private copy of the collection when the setter is called, the content of the collection is lost. See the unit test below.
Issue occurs with version 2.2.10-b140310.1920
Environment
Bug occurs on version 2.2.10-b140310.1920
Affected Versions
[2.2.10]