Skip to content
This repository was archived by the owner on Nov 24, 2020. It is now read-only.

Commit 18504ac

Browse files
fix timeout on android target
1 parent 0706b8b commit 18504ac

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/target/java_android.cr

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,15 @@ END
437437
}
438438
439439
static void createHttpClient() {
440+
if (http != null) {
441+
OkHttpClient.Builder builder = http.newBuilder();
442+
if (interceptor != null)
443+
builder.addNetworkInterceptor(interceptor);
444+
445+
http = builder.build();
446+
return;
447+
}
448+
440449
connectionPool = new ConnectionPool(100, 45, TimeUnit.SECONDS);
441450
442451
TrustManagerFactory trustManagerFactory;
@@ -748,10 +757,7 @@ END
748757
end
749758
end}
750759
sentCount[0] += 1;
751-
if (sentCount[0] >= #{@ast.options.retryRequest ? "22" : "2"}) {
752-
return;
753-
}
754-
if (sentCount[0] >= 25) {
760+
if (sentCount[0] >= 22) {
755761
if (!shouldReceiveResponse[0]) return;
756762
shouldReceiveResponse[0] = false;
757763
timer.cancel();
@@ -763,9 +769,15 @@ END
763769
});
764770
return;
765771
}
772+
773+
if (sentCount[0] >= #{@ast.options.retryRequest ? "22" : "2"}) {
774+
return;
775+
}
776+
766777
if (sentCount[0] % 4 == 0) {
767778
createHttpClient();
768779
}
780+
769781
http.newCall(request).enqueue(new okhttp3.Callback() {
770782
@Override
771783
public void onFailure(Call call, final IOException e) {

0 commit comments

Comments
 (0)