Ignore:
Timestamp:
2019-10-05T00:50:17+02:00 (7 years ago)
Author:
Don-vip
Message:

fix #18190 - Handle "resource:" identical for CachedFile and images

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/CachedFile.java

    r15329 r15416  
    2424import java.util.List;
    2525import java.util.Map;
     26import java.util.Optional;
    2627import java.util.concurrent.ConcurrentHashMap;
    2728import java.util.concurrent.TimeUnit;
     
    3536import org.openstreetmap.josm.tools.Pair;
    3637import org.openstreetmap.josm.tools.PlatformManager;
     38import org.openstreetmap.josm.tools.ResourceProvider;
    3739import org.openstreetmap.josm.tools.Utils;
    3840
     
    4143 *
    4244 * Supports URLs, local files, and a custom scheme (<code>resource:</code>) to get
    43  * resources from the current *.jar file. (Local caching is only done for URLs.)
     45 * resources from the current JOSM *.jar file as well as plugins *.jar files.
     46 * (Local caching is only done for URLs.)
    4447 * <p>
    4548 * The mirrored file is only downloaded if it has been more than 7 days since
     
    225228        if (file == null) {
    226229            if (name != null && name.startsWith("resource://")) {
    227                 String resourceName = name.substring("resource:/".length());
    228                 InputStream is = Utils.getResourceAsStream(getClass(), resourceName);
    229                 if (is == null) {
    230                     throw new IOException(tr("Failed to open input stream for resource ''{0}''", name));
    231                 }
    232                 return is;
     230                return Optional.ofNullable(ResourceProvider.getResourceAsStream(name.substring("resource:/".length())))
     231                        .orElseThrow(() -> new IOException(tr("Failed to open input stream for resource ''{0}''", name)));
    233232            } else {
    234233                throw new IOException("No file found for: "+name);
Note: See TracChangeset for help on using the changeset viewer.