View Full Version : [2.0, Trunk] UnsupportedOperationException from ListStore

23 May 2009, 1:10 PM
I am seeing an UnsupportedOperationException thrown only in web mode. I have traced it back to the onLoad method of ListStore. The externally supplied List is not copied which is bad if someone is handing you an unmodifiable List. Fix below. The changed lines are commented as "defensive copy"

protected void onLoad(LoadEvent le) {
this.config = (ListLoadConfig) le.getConfig();

Object data = le.getData();


if (data instanceof List) {
List<M> list = (List) le.getData();
all = new ArrayList<M>(list); // defensive copy

} else if (data instanceof ListLoadResult) {
all = new ArrayList<M>(((ListLoadResult) data).getData()); // defensive copy