Changeset 15740 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2020-01-20T23:18:38+01:00 (5 years ago)
Author:
simon04
Message:

fix #18588, see #12235 - Comply with OSM Tile Usage Policy

Do not send no-cache headers unless hitting JDK-8146450

Location:
trunk/src/org/openstreetmap/josm
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/ShowStatusReportAction.java

    r15496 r15740  
    7171    }
    7272
    73     private static boolean isRunningJavaWebStart() {
    74         try {
    75             // See http://stackoverflow.com/a/16200769/2257172
    76             return Class.forName("javax.jnlp.ServiceManager") != null;
    77         } catch (ClassNotFoundException e) {
    78             return false;
    79         }
    80     }
    81 
    8273    /**
    8374     * Replies the report header (software and system info)
     
    129120            }
    130121            // Add WebStart package details if run from JNLP
    131             if (isRunningJavaWebStart()) {
     122            if (Utils.isRunningJavaWebStart()) {
    132123                String webStartDetails = platform.getWebStartPackageDetails();
    133124                if (webStartDetails != null) {
  • trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java

    r15573 r15740  
    302302
    303303            Logging.debug("JCS - starting HttpClient GET request for URL: {0}", getUrl());
    304             final HttpClient request = getRequest("GET", true);
     304            final HttpClient request = getRequest("GET");
    305305
    306306            if (isObjectLoadable() &&
     
    487487    }
    488488
    489     private HttpClient getRequest(String requestMethod, boolean noCache) throws IOException {
     489    private HttpClient getRequest(String requestMethod) throws IOException {
    490490        final HttpClient urlConn = HttpClient.create(getUrl(), requestMethod);
    491491        urlConn.setAccept("text/html, image/png, image/jpeg, image/gif, */*");
     
    496496        }
    497497
    498         if (force || noCache) {
    499             urlConn.useCache(false);
    500         }
     498        final boolean noCache = force
     499                // To remove when switching to Java 11
     500                // Workaround for https://bugs.openjdk.java.net/browse/JDK-8146450
     501                || (Utils.getJavaVersion() == 8 && Utils.isRunningJavaWebStart());
     502        urlConn.useCache(!noCache);
     503
    501504        return urlConn;
    502505    }
    503506
    504507    private boolean isCacheValidUsingHead() throws IOException {
    505         final HttpClient.Response urlConn = getRequest("HEAD", false).connect();
     508        final HttpClient.Response urlConn = getRequest("HEAD").connect();
    506509        long lastModified = urlConn.getLastModified();
    507510        boolean ret = (attributes.getEtag() != null && attributes.getEtag().equals(urlConn.getHeaderField("ETag"))) ||
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r15719 r15740  
    18011801
    18021802    /**
     1803     * Determines whether JOSM has been started via Java Web Start.
     1804     * @return true if JOSM has been started via Java Web Start
     1805     * @since 15740
     1806     */
     1807    public static boolean isRunningJavaWebStart() {
     1808        try {
     1809            // See http://stackoverflow.com/a/16200769/2257172
     1810            return Class.forName("javax.jnlp.ServiceManager") != null;
     1811        } catch (ClassNotFoundException e) {
     1812            return false;
     1813        }
     1814    }
     1815
     1816    /**
    18031817     * Get a function that converts an object to a singleton stream of a certain
    18041818     * class (or null if the object cannot be cast to that class).
Note: See TracChangeset for help on using the changeset viewer.