Ignore:
Timestamp:
27.11.2011 11:32:47 (6 months ago)
Author:
bastiK
Message:

see #7088 - Preferences NullPointerException (more checks to find the cause of the error)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/Preferences.java

    r4612 r4614  
    890890 
    891891                valueCopy = new ArrayList<String>(value); 
     892                if (valueCopy.contains(null)) throw new RuntimeException("Error: Null as list element in preference setting (key '"+key+"')"); 
    892893                collectionProperties.put(key, Collections.unmodifiableList(valueCopy)); 
    893894                try { 
     
    10001001 
    10011002                valueCopy = new ArrayList<List<String>>(value.size()); 
     1003                if (valueCopy.contains(null)) throw new RuntimeException("Error: Null as list element in preference setting (key '"+key+"')"); 
    10021004                for (Collection<String> lst : value) { 
    1003                     valueCopy.add(Collections.unmodifiableList(new ArrayList<String>(lst))); 
     1005                    List<String> lstCopy = new ArrayList<String>(lst); 
     1006                    if (lstCopy.contains(null)) throw new RuntimeException("Error: Null as inner list element in preference setting (key '"+key+"')"); 
     1007                    valueCopy.add(Collections.unmodifiableList(lstCopy)); 
    10041008                } 
    10051009                arrayProperties.put(key, Collections.unmodifiableList(valueCopy)); 
     
    10931097 
    10941098                valueCopy = new ArrayList<Map<String, String>>(value.size()); 
     1099                if (valueCopy.contains(null)) throw new RuntimeException("Error: Null as list element in preference setting (key '"+key+"')"); 
    10951100                for (Map<String, String> map : value) { 
    1096                     valueCopy.add(Collections.unmodifiableMap(new LinkedHashMap<String,String>(map))); 
     1101                    Map<String, String> mapCopy = new LinkedHashMap<String,String>(map); 
     1102                    if (mapCopy.keySet().contains(null)) throw new RuntimeException("Error: Null as map key in preference setting (key '"+key+"')"); 
     1103                    if (mapCopy.values().contains(null)) throw new RuntimeException("Error: Null as map value in preference setting (key '"+key+"')"); 
     1104                    valueCopy.add(Collections.unmodifiableMap(mapCopy)); 
    10971105                } 
    10981106                listOfStructsProperties.put(key, Collections.unmodifiableList(valueCopy)); 
Note: See TracChangeset for help on using the changeset viewer.