Okhttp: IndexOutOfBoundsException in RealConnection

Created on 2 Dec 2018  路  5Comments  路  Source: square/okhttp

Stacktrace

java.lang.IndexOutOfBoundsException: Index: 0
    at java.base/java.util.Collections$EmptyList.get(Collections.java:4481)
    at okhttp3.internal.connection.RealConnection.connectTls(RealConnection.java:326)
    at okhttp3.internal.connection.RealConnection.establishProtocol(RealConnection.java:283)
    at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:168)
    at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:257)
    at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:135)
    at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:114)
    at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
    at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
    at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
    at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:126)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
    at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:254)
    at okhttp3.RealCall.execute(RealCall.java:92)

Environment

  • OkHttp 3.12.0
  • Java 11.0.1 LTS
  • Windows 10 64-bit

This bug seems cannot be stably reproduce, so I'm not sure how to write a failing test for this. After I downgraded okhttp to 3.11.0 it works fine.

bug

Most helpful comment

This seems to be rather potent with version 3.12.0, however that version also contains a fix for an issue of 3.11.0 with proxySelector being null on some JVMs. I'm twisted whether I should be using 3.12.0 with this issue or 3.11.0 with the other. I'd much appreciate a fix for this to void that problem.

All 5 comments

Dupe of https://github.com/square/okhttp/issues/4208

Now tracked in https://github.com/square/okhttp/issues/4178. Are you using some particular setup e.g. Pre-Shared Keys?

@andylizi it's also only presumably happening when it fails to verify hostname. Maybe that is what is new, we now don't throw a clean error.

The change with 3.12 could be unrelated but causing this symptom e.g. we do something else differently, causing the verification to fail (which doesn't in 3.11), and then the same code fails here.

Are you using some particular setup e.g. Pre-Shared Keys?

No.... I don't think so.

OkHttpClient client = new OkHttpClient.Builder()
        .connectionPool(connectionPool)
        .protocols(Collections.singletonList(Protocol.HTTP_1_1))
        .retryOnConnectionFailure(false)
        .proxySelector(proxySelector)
        .build();

Request request = new Request.Builder()
        .url(url)
        .get()
        .header(HttpHeaders.ACCEPT, "text/html")
        .build();

try (Response response = client.newCall(request).execute()) {
    // ...
}

SSL Server Test Report provided by ssllabs.com

cert-chain
cipher-suites
protocol-details

I'm also having this issue pls fix

This seems to be rather potent with version 3.12.0, however that version also contains a fix for an issue of 3.11.0 with proxySelector being null on some JVMs. I'm twisted whether I should be using 3.12.0 with this issue or 3.11.0 with the other. I'd much appreciate a fix for this to void that problem.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vanshg picture vanshg  路  3Comments

SElab2019 picture SElab2019  路  3Comments

albka1986 picture albka1986  路  3Comments

yschimke picture yschimke  路  3Comments

rfc2822 picture rfc2822  路  3Comments