Ignore:
Timestamp:
2016-05-15T15:33:36+02:00 (9 years ago)
Author:
donvip
Message:

sonar - squid:S2221 - "Exception" should not be caught when not required by called methods

Location:
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/JMapViewer.java

    r32083 r32180  
    1010import java.awt.event.ActionListener;
    1111import java.awt.event.MouseEvent;
     12import java.net.URL;
    1213import java.util.Collections;
    1314import java.util.LinkedList;
     
    170171        add(zoomSlider);
    171172        int size = 18;
    172         try {
    173             ImageIcon icon = new ImageIcon(JMapViewer.class.getResource("images/plus.png"));
     173        URL url = JMapViewer.class.getResource("images/plus.png");
     174        if (url != null) {
     175            ImageIcon icon = new ImageIcon(url);
    174176            zoomInButton = new JButton(icon);
    175         } catch (Exception e) {
     177        } else {
    176178            zoomInButton = new JButton("+");
    177179            zoomInButton.setFont(new Font("sansserif", Font.BOLD, 9));
     
    188190        zoomInButton.setFocusable(false);
    189191        add(zoomInButton);
    190         try {
    191             ImageIcon icon = new ImageIcon(JMapViewer.class.getResource("images/minus.png"));
     192        url = JMapViewer.class.getResource("images/minus.png");
     193        if (url != null) {
     194            ImageIcon icon = new ImageIcon(url);
    192195            zoomOutButton = new JButton(icon);
    193         } catch (Exception e) {
     196        } else {
    194197            zoomOutButton = new JButton("-");
    195198            zoomOutButton.setFont(new Font("sansserif", Font.BOLD, 9));
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/MemoryTileCache.java

    r31790 r32180  
    7878                removeEntry(lruTiles.getLastElement());
    7979            }
    80         } catch (Exception e) {
     80        } catch (NullPointerException e) {
    8181            log.warning(e.getMessage());
    8282        }
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/OsmTileLoader.java

    r32007 r32180  
    6262                tile.setLoaded(true);
    6363                listener.tileLoadingFinished(tile, true);
    64             } catch (Exception e) {
     64            } catch (IOException e) {
    6565                tile.setError(e.getMessage());
    6666                listener.tileLoadingFinished(tile, false);
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/Tile.java

    r31790 r32180  
    8282        try {
    8383            return ImageIO.read(JMapViewer.class.getResourceAsStream(path));
    84         } catch (Exception ex) {
     84        } catch (IOException | IllegalArgumentException ex) {
    8585            ex.printStackTrace();
    8686            return null;
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/BingAerialTileSource.java

    r32025 r32180  
    290290            }
    291291            return a.toString();
    292         } catch (Exception e) {
     292        } catch (RuntimeException e) {
    293293            e.printStackTrace();
    294294        }
Note: See TracChangeset for help on using the changeset viewer.