Changeset 7706 in josm


Ignore:
Timestamp:
2014-11-04T15:38:17+01:00 (5 years ago)
Author:
stoecker
Message:

don't crash when data image url is broken

File:
1 edited

Legend:

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

    r7695 r7706  
    683683                    }
    684684                }
    685                 if (mediatype != null && mediatype.contains("image/svg+xml")) {
     685                if ("image/svg+xml".equals(mediatype)) {
    686686                    String s = new String(bytes, StandardCharsets.UTF_8);
    687687                    URI uri = getSvgUniverse().loadSVG(new StringReader(s), URLEncoder.encode(s, "UTF-8"));
     
    697697                        // This can be removed if someday Oracle fixes https://bugs.openjdk.java.net/browse/JDK-6788458
    698698                        // hg.openjdk.java.net/jdk7u/jdk7u/jdk/file/828c4fedd29f/src/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java#l656
    699                         return new ImageResource(read(new ByteArrayInputStream(bytes), false, true));
     699                        Image img = read(new ByteArrayInputStream(bytes), false, true);
     700                        return img == null ? null : new ImageResource(img);
    700701                    } catch (IOException e) {
    701702                        Main.warn("IOException while reading image: "+e.getMessage());
Note: See TracChangeset for help on using the changeset viewer.