Modify

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 stoecker)

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 stoecker, 11 months ago

Description: modified (diff)
Summary: Maps/Taiwan WMTS not working - No layer foundDelete Cached file in case of error

comment:2 by GerdP, 10 months ago

A cached file should be deleted when an error occurs.

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.

comment:3 by taylor.smock, 10 months ago

Milestone: 24.0124.02

Ticket retargeted after milestone closed

comment:4 by taylor.smock, 8 months ago

Milestone: 24.0224.03

Ticket retargeted after milestone closed

comment:5 by taylor.smock, 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:

  1. A parsing exception is thrown
  2. A source that is supposed to have layers does not have layers
  3. Other validation checks on the source fail

comment:6 by taylor.smock, 7 months ago

Milestone: 24.0324.04

Ticket retargeted after milestone closed

comment:7 by taylor.smock, 7 months ago

Milestone: 24.0424.05

Ticket retargeted after milestone closed

comment:8 by taylor.smock, 6 months ago

Milestone: 24.0524.06

Ticket retargeted after milestone closed

comment:9 by stoecker, 5 months ago

Milestone: 24.0624.07

Milestone closed.

comment:10 by taylor.smock, 4 months ago

Milestone: 24.0724.08

Ticket retargeted after milestone closed

comment:11 by taylor.smock, 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  
    2020import java.security.NoSuchAlgorithmException;
    2121import java.util.ArrayList;
    2222import java.util.Arrays;
     23import java.util.Collection;
    2324import java.util.Enumeration;
    2425import java.util.List;
    2526import java.util.Map;
    2627import java.util.Optional;
     28import java.util.concurrent.Callable;
    2729import java.util.concurrent.ConcurrentHashMap;
    2830import java.util.concurrent.TimeUnit;
    2931import java.util.zip.ZipEntry;
     
    335337        return ze.b;
    336338    }
    337339
     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
    338359    private Pair<String, InputStream> findZipEntryImpl(String extension, String namepart) {
    339360        File file = null;
    340361        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:12 by taylor.smock, 3 months ago

Milestone: 24.0824.09

Ticket retargeted after milestone closed

comment:13 by taylor.smock, 7 weeks ago

Milestone: 24.0924.10

Ticket retargeted after milestone closed

comment:14 by taylor.smock, 3 weeks ago

Milestone: 24.1024.11

Ticket retargeted after milestone closed

comment:15 by stoecker, 4 days ago

Milestone: 24.11

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The owner will remain team.
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from team to the specified user.
Next status will be 'needinfo'. The owner will be changed from team to stoecker.
as duplicate The resolution will be set to duplicate. Next status will be 'closed'. The specified ticket will be cross-referenced with this ticket.
The owner will be changed from team to anonymous. Next status will be 'assigned'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.