- Timestamp:
- 2018-02-22T20:40:18+01:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJob.java
r13029 r13449 7 7 import java.io.IOException; 8 8 import java.net.URL; 9 import java.nio.charset.StandardCharsets; 9 10 import java.util.HashSet; 10 11 import java.util.List; … … 17 18 import java.util.concurrent.ThreadPoolExecutor; 18 19 import java.util.concurrent.TimeUnit; 20 import java.util.regex.Matcher; 21 import java.util.regex.Pattern; 19 22 20 23 import org.apache.commons.jcs.access.behavior.ICacheAccess; … … 42 45 private static final LongProperty MAXIMUM_EXPIRES = new LongProperty("imagery.generic.maximum_expires", TimeUnit.DAYS.toMillis(30)); 43 46 private static final LongProperty MINIMUM_EXPIRES = new LongProperty("imagery.generic.minimum_expires", TimeUnit.HOURS.toMillis(1)); 47 private static final Pattern SERVICE_EXCEPTION_PATTERN = Pattern.compile("(?s).+<ServiceException>(.+)</ServiceException>.+"); 44 48 protected final Tile tile; 45 49 private volatile URL url; … … 270 274 byte[] content = object.getContent(); 271 275 if (content.length > 0) { 272 try { 273 tile.loadImage(new ByteArrayInputStream(content)); 276 try (ByteArrayInputStream in = new ByteArrayInputStream(content)) { 277 tile.loadImage(in); 278 if (tile.getImage() == null) { 279 String s = new String(content, StandardCharsets.UTF_8); 280 Matcher m = SERVICE_EXCEPTION_PATTERN.matcher(s); 281 if (m.matches()) { 282 tile.setError(m.group(1)); 283 Logging.error(m.group(1)); 284 Logging.debug(s); 285 } else { 286 tile.setError(tr("Could not load image from tile server")); 287 } 288 return false; 289 } 274 290 } catch (UnsatisfiedLinkError e) { 275 291 throw new IOException(e); 276 292 } 277 if (tile.getImage() == null) {278 tile.setError(tr("Could not load image from tile server"));279 return false;280 }281 293 } 282 294 }
Note:
See TracChangeset
for help on using the changeset viewer.