Ignore:
Timestamp:
2016-05-16T04:05:58+02:00 (8 years ago)
Author:
Don-vip
Message:

findbugs: DP_DO_INSIDE_DO_PRIVILEGED + UWF_UNWRITTEN_FIELD + RC_REF_COMPARISON + OBL_UNSATISFIED_OBLIGATION_EXCEPTION_EDGE

File:
1 edited

Legend:

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

    r10212 r10223  
    12031203            structPrototype = klass.getConstructor().newInstance();
    12041204        } catch (ReflectiveOperationException ex) {
    1205             throw new RuntimeException(ex);
     1205            throw new IllegalArgumentException(ex);
    12061206        }
    12071207
     
    12111211                continue;
    12121212            }
    1213             f.setAccessible(true);
     1213            Utils.setObjectsAccessible(f);
    12141214            try {
    12151215                Object fieldValue = f.get(struct);
    12161216                Object defaultFieldValue = f.get(structPrototype);
    1217                 if (fieldValue != null) {
    1218                     if (f.getAnnotation(writeExplicitly.class) != null || !Objects.equals(fieldValue, defaultFieldValue)) {
    1219                         String key = f.getName().replace('_', '-');
    1220                         if (fieldValue instanceof Map) {
    1221                             hash.put(key, mapToJson((Map) fieldValue));
    1222                         } else if (fieldValue instanceof MultiMap) {
    1223                             hash.put(key, multiMapToJson((MultiMap) fieldValue));
    1224                         } else {
    1225                             hash.put(key, fieldValue.toString());
    1226                         }
     1217                if (fieldValue != null && (f.getAnnotation(writeExplicitly.class) != null || !Objects.equals(fieldValue, defaultFieldValue))) {
     1218                    String key = f.getName().replace('_', '-');
     1219                    if (fieldValue instanceof Map) {
     1220                        hash.put(key, mapToJson((Map<?, ?>) fieldValue));
     1221                    } else if (fieldValue instanceof MultiMap) {
     1222                        hash.put(key, multiMapToJson((MultiMap<?, ?>) fieldValue));
     1223                    } else {
     1224                        hash.put(key, fieldValue.toString());
    12271225                    }
    12281226                }
    1229             } catch (IllegalArgumentException | IllegalAccessException ex) {
     1227            } catch (IllegalAccessException ex) {
    12301228                throw new RuntimeException(ex);
    12311229            }
     
    12611259            } catch (NoSuchFieldException ex) {
    12621260                continue;
    1263             } catch (SecurityException ex) {
    1264                 throw new RuntimeException(ex);
    12651261            }
    12661262            if (f.getAnnotation(pref.class) == null) {
    12671263                continue;
    12681264            }
    1269             f.setAccessible(true);
     1265            Utils.setObjectsAccessible(f);
    12701266            if (f.getType() == Boolean.class || f.getType() == boolean.class) {
    12711267                value = Boolean.valueOf(key_value.getValue());
     
    13261322            try {
    13271323                Field field = Toolkit.class.getDeclaredField("resources");
    1328                 field.setAccessible(true);
     1324                Utils.setObjectsAccessible(field);
    13291325                field.set(null, ResourceBundle.getBundle("sun.awt.resources.awt"));
    13301326            } catch (ReflectiveOperationException e) {
Note: See TracChangeset for help on using the changeset viewer.