PDA

View Full Version : [OPEN] [FIXED] [1.2.3] BaseModel.remove(String) should check for null hashmap



xferron
22 Mar 2009, 5:28 AM
Java 1.5
Mac OSX
GXT 1.2.3

If you instantiate BaseModel and then immediately use the remove() method, a NPE will be thrown. Looks like the underlying hash map is lazily created. BaseModel's parent actually does do a null check, but BaseModel overrides the parent method and uses the map without checking for null.

Original 1.2.3 Code:


public <X> X remove(String name) {
if (map.containsKey(name)) {
X oldValue = (X) super.remove(name);
notifyPropertyChanged(name, null, oldValue);
return oldValue;
}
return null;
}


The FIX:


public <X> X remove(String name) {
if (map != null && map.containsKey(name)) {
X oldValue = (X) super.remove(name);
notifyPropertyChanged(name, null, oldValue);
return oldValue;
}
return null;
}

sven
1 Apr 2009, 4:17 AM
Fixed in SVN.