Ignore:
Timestamp:
2015-06-12T22:51:43+02:00 (11 years ago)
Author:
wiktorn
Message:

Properly handle situation, when tile server returns something else than image file but still gives http status code 200 (like html error page). Closes #11553

File:
1 edited

Legend:

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

    r8470 r8488  
    2020    private transient volatile BufferedImage img = null;
    2121    private transient volatile boolean writtenToDisk = false;
     22    // we need to have separate control variable, to know, if we already tried to load the image, as img might be null
     23    // after we loaded image, as for example, when image file is malformed (eg. HTML file)
     24    private transient volatile boolean imageLoaded = false;
    2225
    2326    /**
     
    3740     */
    3841    public BufferedImage getImage() throws IOException {
    39         if (img != null)
     42        if (imageLoaded)
    4043            return img;
    4144        synchronized(this) {
    42             if (img != null)
     45            if (imageLoaded)
    4346                return img;
    4447            byte[] content = getContent();
    4548            if (content != null && content.length > 0) {
    4649                img = ImageIO.read(new ByteArrayInputStream(content));
     50                imageLoaded = true;
    4751
    4852                if (writtenToDisk)
Note: See TracChangeset for help on using the changeset viewer.