Fix: app won't start, if cache is disabled
This commit is contained in:
parent
1cf2d35f74
commit
f926f784b3
|
@ -43,7 +43,6 @@ public abstract class HttpClient {
|
||||||
protected CookieJarImpl cookieJar;
|
protected CookieJarImpl cookieJar;
|
||||||
protected Config config;
|
protected Config config;
|
||||||
protected boolean loggedIn = false;
|
protected boolean loggedIn = false;
|
||||||
protected int loginTries = 0;
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
protected HttpClient(String name, Config config) {
|
protected HttpClient(String name, Config config) {
|
||||||
|
@ -105,13 +104,17 @@ public abstract class HttpClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Response execute(Request req) throws IOException {
|
public Response execute(Request req) throws IOException {
|
||||||
log.trace("Cache hit ratio {}/{} = {}", cache.hitCount(), cache.requestCount(), NumberFormat.getPercentInstance().format(cache.hitCount() / (double) cache.requestCount()));
|
if (cache != null) {
|
||||||
|
log.trace("Cache hit ratio {}/{} = {}", cache.hitCount(), cache.requestCount(), NumberFormat.getPercentInstance().format(cache.hitCount() / (double) cache.requestCount()));
|
||||||
|
}
|
||||||
Response resp = client.newCall(req).execute();
|
Response resp = client.newCall(req).execute();
|
||||||
return resp;
|
return resp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Response execute(Request request, int timeoutInMillis) throws IOException {
|
public Response execute(Request request, int timeoutInMillis) throws IOException {
|
||||||
log.trace("Cache hit ratio {}/{} = {}", cache.hitCount(), cache.requestCount(), NumberFormat.getPercentInstance().format(cache.hitCount() / (double) cache.requestCount()));
|
if (cache != null) {
|
||||||
|
log.trace("Cache hit ratio {}/{} = {}", cache.hitCount(), cache.requestCount(), NumberFormat.getPercentInstance().format(cache.hitCount() / (double) cache.requestCount()));
|
||||||
|
}
|
||||||
return client.newBuilder() //
|
return client.newBuilder() //
|
||||||
.connectTimeout(timeoutInMillis, TimeUnit.MILLISECONDS) //
|
.connectTimeout(timeoutInMillis, TimeUnit.MILLISECONDS) //
|
||||||
.readTimeout(timeoutInMillis, TimeUnit.MILLISECONDS).build() //
|
.readTimeout(timeoutInMillis, TimeUnit.MILLISECONDS).build() //
|
||||||
|
|
Loading…
Reference in New Issue