Ignore:
Timestamp:
2017-10-21T14:17:17+02:00 (7 years ago)
Author:
Don-vip
Message:

fix #15462 - catch UnsatisfiedLinkError in case of JRE badly installed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJob.java

    r12865 r13029  
    160160
    161161        try {
    162                 tile.finishLoading(); // whatever happened set that loading has finished
    163                 // set tile metadata
    164                 if (this.attributes != null) {
    165                     for (Entry<String, String> e: this.attributes.getMetadata().entrySet()) {
    166                         tile.putValue(e.getKey(), e.getValue());
     162            tile.finishLoading(); // whatever happened set that loading has finished
     163            // set tile metadata
     164            if (this.attributes != null) {
     165                for (Entry<String, String> e: this.attributes.getMetadata().entrySet()) {
     166                    tile.putValue(e.getKey(), e.getValue());
     167                }
     168            }
     169
     170            switch(result) {
     171            case SUCCESS:
     172                handleNoTileAtZoom();
     173                if (attributes != null) {
     174                    int httpStatusCode = attributes.getResponseCode();
     175                    if (httpStatusCode >= 400 && !isNoTileAtZoom()) {
     176                        if (attributes.getErrorMessage() == null) {
     177                            tile.setError(tr("HTTP error {0} when loading tiles", httpStatusCode));
     178                        } else {
     179                            tile.setError(tr("Error downloading tiles: {0}", attributes.getErrorMessage()));
     180                        }
     181                        status = false;
    167182                    }
    168183                }
    169 
    170                 switch(result) {
    171                 case SUCCESS:
    172                     handleNoTileAtZoom();
    173                     if (attributes != null) {
    174                         int httpStatusCode = attributes.getResponseCode();
    175                         if (httpStatusCode >= 400 && !isNoTileAtZoom()) {
    176                             if (attributes.getErrorMessage() == null) {
    177                                 tile.setError(tr("HTTP error {0} when loading tiles", httpStatusCode));
    178                             } else {
    179                                 tile.setError(tr("Error downloading tiles: {0}", attributes.getErrorMessage()));
    180                             }
    181                             status = false;
    182                         }
    183                     }
    184                     status &= tryLoadTileImage(object); //try to keep returned image as background
    185                     break;
    186                 case FAILURE:
    187                     tile.setError("Problem loading tile");
    188                     tryLoadTileImage(object);
    189                     break;
    190                 case CANCELED:
    191                     tile.loadingCanceled();
    192                     // do nothing
    193                 }
     184                status &= tryLoadTileImage(object); //try to keep returned image as background
     185                break;
     186            case FAILURE:
     187                tile.setError("Problem loading tile");
     188                tryLoadTileImage(object);
     189                break;
     190            case CANCELED:
     191                tile.loadingCanceled();
     192                // do nothing
     193            }
    194194
    195195            // always check, if there is some listener interested in fact, that tile has finished loading
     
    270270            byte[] content = object.getContent();
    271271            if (content.length > 0) {
    272                 tile.loadImage(new ByteArrayInputStream(content));
     272                try {
     273                    tile.loadImage(new ByteArrayInputStream(content));
     274                } catch (UnsatisfiedLinkError e) {
     275                    throw new IOException(e);
     276                }
    273277                if (tile.getImage() == null) {
    274278                    tile.setError(tr("Could not load image from tile server"));
Note: See TracChangeset for help on using the changeset viewer.