Ignore:
Timestamp:
2016-12-14T15:50:53+01:00 (3 years ago)
Author:
Don-vip
Message:

sonar - squid:S2259 - Null pointers should not be dereferenced

Location:
trunk/src/org/openstreetmap/josm/tools
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/AudioPlayer.java

    r11100 r11397  
    124124     */
    125125    public static void play(URL url) throws Exception {
    126         AudioPlayer.getInstance().command.play(url, 0.0, 1.0);
     126        AudioPlayer instance = AudioPlayer.getInstance();
     127        if (instance != null)
     128            instance.command.play(url, 0.0, 1.0);
    127129    }
    128130
     
    134136     */
    135137    public static void play(URL url, double seconds) throws Exception {
    136         AudioPlayer.getInstance().command.play(url, seconds, 1.0);
     138        AudioPlayer instance = AudioPlayer.getInstance();
     139        if (instance != null)
     140            instance.command.play(url, seconds, 1.0);
    137141    }
    138142
     
    145149     */
    146150    public static void play(URL url, double seconds, double speed) throws Exception {
    147         AudioPlayer.getInstance().command.play(url, seconds, speed);
     151        AudioPlayer instance = AudioPlayer.getInstance();
     152        if (instance != null)
     153            instance.command.play(url, seconds, speed);
    148154    }
    149155
     
    153159     */
    154160    public static void pause() throws Exception {
    155         AudioPlayer.getInstance().command.pause();
     161        AudioPlayer instance = AudioPlayer.getInstance();
     162        if (instance != null)
     163            instance.command.pause();
    156164    }
    157165
     
    161169     */
    162170    public static URL url() {
    163         return AudioPlayer.getInstance().playingUrl;
     171        AudioPlayer instance = AudioPlayer.getInstance();
     172        return instance == null ? null : instance.playingUrl;
    164173    }
    165174
     
    169178     */
    170179    public static boolean paused() {
    171         return AudioPlayer.getInstance().state == State.PAUSED;
     180        AudioPlayer instance = AudioPlayer.getInstance();
     181        return instance == null ? false : (instance.state == State.PAUSED);
    172182    }
    173183
     
    177187     */
    178188    public static boolean playing() {
    179         return AudioPlayer.getInstance().state == State.PLAYING;
     189        AudioPlayer instance = AudioPlayer.getInstance();
     190        return instance == null ? false : (instance.state == State.PLAYING);
    180191    }
    181192
     
    185196     */
    186197    public static double position() {
    187         return AudioPlayer.getInstance().position;
     198        AudioPlayer instance = AudioPlayer.getInstance();
     199        return instance == null ? -1 : instance.position;
    188200    }
    189201
     
    193205     */
    194206    public static double speed() {
    195         return AudioPlayer.getInstance().speed;
     207        AudioPlayer instance = AudioPlayer.getInstance();
     208        return instance == null ? -1 : instance.speed;
    196209    }
    197210
  • trunk/src/org/openstreetmap/josm/tools/ExceptionUtil.java

    r10717 r11397  
    510510        return tr("<html>Failed to upload data to or download data from<br>" + "''{0}''<br>"
    511511                + "due to a problem with transferring data.<br>"
    512                 + "Details (untranslated): {1}</html>", e.getUrl(),
     512                + "Details (untranslated): {1}</html>",
     513                e != null ? e.getUrl() : "null",
    513514                ioe != null ? ioe.getMessage() : "null");
    514515    }
  • trunk/src/org/openstreetmap/josm/tools/Logging.java

    r11165 r11397  
    261261        StringWriter sb = new StringWriter();
    262262        sb.append(getErrorLog(message, t));
    263         sb.append('\n');
    264         t.printStackTrace(new PrintWriter(sb));
     263        if (t != null) {
     264            sb.append('\n');
     265            t.printStackTrace(new PrintWriter(sb));
     266        }
    265267        return sb.toString();
    266268    }
  • trunk/src/org/openstreetmap/josm/tools/Shortcut.java

    r11340 r11397  
    205205
    206206    public boolean isEvent(KeyEvent e) {
    207         return getKeyStroke() != null && getKeyStroke().equals(
    208         KeyStroke.getKeyStroke(e.getKeyCode(), e.getModifiers()));
     207        KeyStroke ks = getKeyStroke();
     208        return ks != null && ks.equals(KeyStroke.getKeyStroke(e.getKeyCode(), e.getModifiers()));
    209209    }
    210210
Note: See TracChangeset for help on using the changeset viewer.