Ignore:
Timestamp:
2015-07-15T21:20:51+02:00 (9 years ago)
Author:
wiktorn
Message:

Better error reporting in JCS, checkstyle fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java

    r8602 r8604  
    199199     */
    200200    protected boolean isObjectLoadable() {
     201        if (cacheData == null) {
     202            return false;
     203        }
    201204        byte[] content = cacheData.getContent();
    202205        return content != null && content.length > 0;
     
    338341
    339342                attributes.setResponseCode(urlConn.getResponseCode());
    340                 byte[] raw = Utils.readBytesFromStream(urlConn.getInputStream());
     343                byte[] raw;
     344                if (urlConn.getResponseCode() == 200) {
     345                    raw = Utils.readBytesFromStream(urlConn.getInputStream());
     346                } else {
     347                    raw = new byte[]{};
     348                }
    341349
    342350                if (isResponseLoadable(urlConn.getHeaderFields(), urlConn.getResponseCode(), raw)) {
     
    440448        urlConn.setReadTimeout(readTimeout); // 30 seconds read timeout
    441449        urlConn.setConnectTimeout(connectTimeout);
    442         for (Map.Entry<String, String> e: headers.entrySet()) {
    443             urlConn.setRequestProperty(e.getKey(), e.getValue());
     450        if (headers != null) {
     451            for (Map.Entry<String, String> e: headers.entrySet()) {
     452                urlConn.setRequestProperty(e.getKey(), e.getValue());
     453            }
    444454        }
    445455        if (force) {
Note: See TracChangeset for help on using the changeset viewer.