Results 1 to 2 of 2

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

  1. #1
    Ext User
    Join Date
    Jan 2009
    Posts
    18
    Vote Rating
    0
      0  

    Default [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
    Sencha Premium Member
    Join Date
    Sep 2007
    Posts
    13,976
    Vote Rating
    132
      0  

    Default

    Fixed in SVN.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •