Ignore:
Timestamp:
2017-03-19T02:26:34+01:00 (7 years ago)
Author:
Don-vip
Message:

PMD - Strict Exceptions

Location:
trunk/src/org/openstreetmap/josm/data
Files:
10 edited

Legend:

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

    r11288 r11746  
    233233                    GuiHelper.runInEDT(this::displayNotification);
    234234                }
    235             } catch (RuntimeException t) {
     235            } catch (RuntimeException t) { // NOPMD
    236236                // Don't let exception stop time thread
    237237                Main.error("Autosave failed:");
  • trunk/src/org/openstreetmap/josm/data/Preferences.java

    r11728 r11746  
    14201420                Utils.setObjectsAccessible(field);
    14211421                field.set(null, ResourceBundle.getBundle("sun.awt.resources.awt"));
    1422             } catch (ReflectiveOperationException | RuntimeException e) {
     1422            } catch (ReflectiveOperationException | RuntimeException e) { // NOPMD
     1423                // Catch RuntimeException in order to catch InaccessibleObjectException, new in Java 9
    14231424                Main.warn(e);
    14241425            }
  • trunk/src/org/openstreetmap/josm/data/cache/JCSCacheManager.java

    r11400 r11746  
    182182            } catch (IOException e) {
    183183                throw e;
    184             } catch (Exception e) {
     184            } catch (Exception e) { // NOPMD
    185185                throw new IOException(e);
    186186            }
  • trunk/src/org/openstreetmap/josm/data/osm/DatasetConsistencyTest.java

    r10627 r11746  
    99
    1010import org.openstreetmap.josm.Main;
     11import org.openstreetmap.josm.tools.JosmRuntimeException;
    1112import org.openstreetmap.josm.tools.Utils;
    1213
     
    212213            }
    213214
    214         } catch (RuntimeException e) {
     215        } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException e) {
    215216            writer.println("Exception during dataset integrity test:");
    216217            e.printStackTrace(writer);
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java

    r11731 r11746  
    8686import org.openstreetmap.josm.tools.Geometry.AreaAndPerimeter;
    8787import org.openstreetmap.josm.tools.ImageProvider;
     88import org.openstreetmap.josm.tools.JosmRuntimeException;
    8889import org.openstreetmap.josm.tools.Utils;
    8990import org.openstreetmap.josm.tools.bugreport.BugReport;
     
    17351736                }
    17361737                return output;
    1737             } catch (RuntimeException e) {
     1738            } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException e) {
    17381739                throw BugReport.intercept(e).put("input-size", input.size()).put("output-size", output.size());
    17391740            } finally {
     
    17471748                    osm.accept(this);
    17481749                }
    1749             } catch (RuntimeException e) {
     1750            } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException e) {
    17501751                throw BugReport.intercept(e).put("osm", osm);
    17511752            }
     
    18551856
    18561857            benchmark.renderDone();
    1857         } catch (RuntimeException e) {
     1858        } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException e) {
    18581859            throw BugReport.intercept(e)
    18591860                    .put("data", data)
     
    18701871        try {
    18711872            record.paintPrimitive(paintSettings, this);
    1872         } catch (RuntimeException e) {
     1873        } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException e) {
    18731874            throw BugReport.intercept(e).put("record", record);
    18741875        }
  • trunk/src/org/openstreetmap/josm/data/preferences/PreferencesWriter.java

    r11553 r11746  
    8888            addDefaults();
    8989        } else {
    90             throw new NullPointerException();
     90            throw new IllegalArgumentException(setting.toString());
    9191        }
    9292    }
     
    105105            addDefaults();
    106106        } else {
    107             throw new NullPointerException();
     107            throw new IllegalArgumentException(setting.toString());
    108108        }
    109109    }
     
    126126            addDefaults();
    127127        } else {
    128             throw new NullPointerException();
     128            throw new IllegalArgumentException(setting.toString());
    129129        }
    130130    }
     
    147147            addDefaults();
    148148        } else {
    149             throw new NullPointerException();
     149            throw new IllegalArgumentException(setting.toString());
    150150        }
    151151    }
  • trunk/src/org/openstreetmap/josm/data/projection/CustomProjection.java

    r11553 r11746  
    3232import org.openstreetmap.josm.data.projection.proj.Proj;
    3333import org.openstreetmap.josm.data.projection.proj.ProjParameters;
     34import org.openstreetmap.josm.tools.JosmRuntimeException;
    3435import org.openstreetmap.josm.tools.Utils;
    3536import org.openstreetmap.josm.tools.bugreport.BugReport;
     
    831832                        }
    832833                    }
    833                 } catch (RuntimeException e) {
     834                } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException e) {
    834835                    Main.error(e);
    835836                }
  • trunk/src/org/openstreetmap/josm/data/projection/Projections.java

    r11642 r11746  
    338338            try {
    339339                proj = pc.getProjection();
    340             } catch (RuntimeException e) {
     340            } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException e) {
    341341                Main.warn(e, "Unable to get projection "+code+" with "+pc+':');
    342342            }
  • trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java

    r11594 r11746  
    333333                    test.initialize();
    334334                }
    335             } catch (Exception e) {
     335            } catch (Exception e) { // NOPMD
    336336                Main.error(e);
    337337                if (!GraphicsEnvironment.isHeadless()) {
  • trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java

    r11385 r11746  
    271271                for (TaggingPresetItem i : p.data) {
    272272                    if (i instanceof KeyedItem) {
    273                         addPresetValue(p, (KeyedItem) i);
     273                        addPresetValue((KeyedItem) i);
    274274                    } else if (i instanceof CheckGroup) {
    275275                        for (Check c : ((CheckGroup) i).checks) {
    276                             addPresetValue(p, c);
     276                            addPresetValue(c);
    277277                        }
    278278                    }
     
    282282    }
    283283
    284     private static void addPresetValue(TaggingPreset p, KeyedItem ky) {
     284    private static void addPresetValue(KeyedItem ky) {
    285285        Collection<String> values = ky.getValues();
    286286        if (ky.key != null && values != null) {
    287             try {
    288                 presetsValueData.putAll(ky.key, values);
    289                 harmonizedKeys.put(harmonizeKey(ky.key), ky.key);
    290             } catch (NullPointerException e) {
    291                 Main.error(e, p+": Unable to initialize "+ky+'.');
    292             }
     287            presetsValueData.putAll(ky.key, values);
     288            harmonizedKeys.put(harmonizeKey(ky.key), ky.key);
    293289        }
    294290    }
     
    543539
    544540    private static String harmonizeKey(String key) {
    545         key = key.toLowerCase(Locale.ENGLISH).replace('-', '_').replace(':', '_').replace(' ', '_');
    546         return Utils.strip(key, "-_;:,");
     541        return Utils.strip(key.toLowerCase(Locale.ENGLISH).replace('-', '_').replace(':', '_').replace(' ', '_'), "-_;:,");
    547542    }
    548543
    549544    private static String harmonizeValue(String value) {
    550         value = value.toLowerCase(Locale.ENGLISH).replace('-', '_').replace(' ', '_');
    551         return Utils.strip(value, "-_;:,");
     545        return Utils.strip(value.toLowerCase(Locale.ENGLISH).replace('-', '_').replace(' ', '_'), "-_;:,");
    552546    }
    553547
Note: See TracChangeset for help on using the changeset viewer.