vertigo-core icon indicating copy to clipboard operation
vertigo-core copied to clipboard

ListVAccessor.get() should return an unmodifiable DtList

Open ojathelonius opened this issue 7 years ago • 1 comments

Is there a point in allowing the modification of DtLists returned by the Accessor from the database ?

See example :


// after load()

final DtList<CustomObject> elements = myObject.elements().get();
final DtList<CustomObject> otherElements = otherObject.elements().get();

elements.addAll(otherElements);

In the example above, otherElements will be stacked on top of elements every time the code runs, which is probably not the desired outcome since myObject.elements().get() is expected to be pristine data.

ListVAccessor.get() could return an unmodifiable DtList instead.

ojathelonius avatar Jun 14 '18 14:06 ojathelonius

Even more dangerous if myObject is a ref element shared by all threads. A buggy code in one place can mess up all.

skerdudou avatar Jun 19 '18 13:06 skerdudou