Skip to content

Commit

Permalink
skip creation of local var in proxyhandler.storetocache
Browse files Browse the repository at this point in the history
  • Loading branch information
reger committed Nov 9, 2014
1 parent 8a4a292 commit e4316e2
Showing 1 changed file with 19 additions and 21 deletions.
40 changes: 19 additions & 21 deletions source/net/yacy/http/ProxyHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,32 +112,30 @@ private void deleteFromCache(final byte[] hash) {
}
}

private void storeToCache(final Response response, final byte[] array) {
private void storeToCache(final Response yacyResponse, final byte[] cacheArray) {
final Thread t = new Thread() {
final Response yacyResponse = response;
final byte[] cacheArray = array;
@Override
@Override
public void run() {
this.setName("ProxyHandler.storeToCache(" + yacyResponse.url() + ")");
if (yacyResponse == null) return;

// the cache does either not exist or is (supposed to be) stale
deleteFromCache(yacyResponse.url().hash());
if (yacyResponse == null) return;
this.setName("ProxyHandler.storeToCache(" + yacyResponse.url() + ")");

if (cacheArray == null || cacheArray.length <= 0) return;
// the cache does either not exist or is (supposed to be) stale
deleteFromCache(yacyResponse.url().hash());

yacyResponse.setContent(cacheArray);
try {
Cache.store(yacyResponse.url(), yacyResponse.getResponseHeader(), cacheArray);
sb.toIndexer(yacyResponse);
} catch (IOException e) {
//log.logWarning("cannot write " + response.url() + " to Cache (1): " + e.getMessage(), e);
}
if (cacheArray == null || cacheArray.length <= 0) return;

yacyResponse.setContent(cacheArray);
try {
Cache.store(yacyResponse.url(), yacyResponse.getResponseHeader(), cacheArray);
sb.toIndexer(yacyResponse);
} catch (IOException e) {
//log.logWarning("cannot write " + response.url() + " to Cache (1): " + e.getMessage(), e);
}
};
t.setPriority(Thread.MIN_PRIORITY);
t.start();
}
}
};
t.setPriority(Thread.MIN_PRIORITY);
t.start();
}

@Override
public void handleRemote(String target, Request baseRequest, HttpServletRequest request,
Expand Down

0 comments on commit e4316e2

Please sign in to comment.