1. #1
    Ext User
    Join Date
    Jan 2009
    Posts
    18
    Vote Rating
    0
    xferron is on a distinguished road

      0  

    Default [FIXED] [1.2.3] BaseModel.remove(String) should check for null hashmap

    [FIXED] [1.2.3] BaseModel.remove(String) should check for null hashmap


    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:
    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:
    Code:
      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;
      }

  2. #2
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,691
    Vote Rating
    107
    sven is just really nice sven is just really nice sven is just really nice sven is just really nice

      0  

    Default


    Fixed in SVN.