Opened 11 months ago
Last modified 4 days ago
#23374 new defect
Delete Cached file in case of error
Reported by: | stoecker | Owned by: | team |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | Core imagery | Version: | |
Keywords: | Cc: |
Description (last modified by )
The URL https://maps.nlsc.gov.tw/OpenData/wmts? doesn't work. JOSM can't find any layer, but on first view the XML looks good to me.
Reason: The server delivered (for a short time?) a XML without Layers. This was cached and used again and again.
A cached file should be deleted when an error occurs.
Attachments (0)
Change History (15)
comment:1 by , 11 months ago
Description: | modified (diff) |
---|---|
Summary: | Maps/Taiwan WMTS not working - No layer found → Delete Cached file in case of error |
comment:2 by , 10 months ago
comment:5 by , 8 months ago
Any idea how to achive that?
Probably a try-catch block if an exception is thrown. Problem being, I don't think there was an exception thrown here.
We could try reloading entries (on some kind of backoff function to avoid overloading the server) if the following is true:
- A parsing exception is thrown
- A source that is supposed to have layers does not have layers
- Other validation checks on the source fail
comment:11 by , 4 months ago
We could try doing something like this:
-
src/org/openstreetmap/josm/io/CachedFile.java
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 diff --git a/src/org/openstreetmap/josm/io/CachedFile.java b/src/org/openstreetmap/josm/io/CachedFile.java
a b 20 20 import java.security.NoSuchAlgorithmException; 21 21 import java.util.ArrayList; 22 22 import java.util.Arrays; 23 import java.util.Collection; 23 24 import java.util.Enumeration; 24 25 import java.util.List; 25 26 import java.util.Map; 26 27 import java.util.Optional; 28 import java.util.concurrent.Callable; 27 29 import java.util.concurrent.ConcurrentHashMap; 28 30 import java.util.concurrent.TimeUnit; 29 31 import java.util.zip.ZipEntry; … … 335 337 return ze.b; 336 338 } 337 339 340 /** 341 * Perform parsing of the local file. In the event that a specified set of exceptions occur, we clear the file 342 * and rethrow the exception. 343 * @param runnable The callable that may throw an exception 344 * @param improperLocalFile The list of exceptions that indicate that we need to redownload the file 345 * @param <T> The callable return type 346 * @throws Exception 347 */ 348 public <T> T performParsing(Callable<T> runnable, Collection<Class<? extends Throwable>> improperLocalFile) throws Exception { 349 try { 350 return runnable.call(); 351 } catch (Exception throwable) { 352 if (improperLocalFile.contains(throwable.getClass())) { 353 this.clear(); 354 } 355 throw throwable; 356 } 357 } 358 338 359 private Pair<String, InputStream> findZipEntryImpl(String extension, String namepart) { 339 360 File file = null; 340 361 try {
I'm not certain if I want to do that in CachedFile
or if we want to try and do that in catch
blocks for all the places where we use CachedFile
.
comment:15 by , 4 days ago
Milestone: | 24.11 |
---|
Any idea how to achive that?
My understanding is that any code where
CachedFile
is used hast to be checked and changed to make sure that any kind of malformed data causes a delete from the cache.