Changeset 13648 in josm for trunk/src/org/openstreetmap/josm


Ignore:
Timestamp:
2018-04-19T21:36:20+02:00 (18 months ago)
Author:
Don-vip
Message:

see #16204 - allow to load embedded images by disabling ImageIO cache in case of SecurityException

File:
1 edited

Legend:

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

    r13647 r13648  
    16561656        }
    16571657
    1658         ImageInputStream stream = ImageIO.createImageInputStream(input);
     1658        ImageInputStream stream = createImageInputStream(input);
    16591659        if (stream == null) {
    16601660            throw new IIOException("Can't create an ImageInputStream!");
     
    17061706        CheckParameterUtil.ensureParameterNotNull(input, "input");
    17071707
    1708         ImageInputStream stream = ImageIO.createImageInputStream(input);
     1708        ImageInputStream stream = createImageInputStream(input);
    17091709        BufferedImage bi = read(stream, readMetadata, enforceTransparency);
    17101710        if (bi == null) {
     
    17501750
    17511751        try (InputStream istream = Utils.openStream(input)) {
    1752             ImageInputStream stream = ImageIO.createImageInputStream(istream);
     1752            ImageInputStream stream = createImageInputStream(istream);
    17531753            BufferedImage bi = read(stream, readMetadata, enforceTransparency);
    17541754            if (bi == null) {
     
    20162016        return buffImage;
    20172017    }
     2018
     2019    private static ImageInputStream createImageInputStream(Object input) throws IOException {
     2020        try {
     2021            return ImageIO.createImageInputStream(input);
     2022        } catch (SecurityException e) {
     2023            if (ImageIO.getUseCache()) {
     2024                ImageIO.setUseCache(false);
     2025                return ImageIO.createImageInputStream(input);
     2026            }
     2027            throw new IOException(e);
     2028        }
     2029    }
    20182030}
Note: See TracChangeset for help on using the changeset viewer.