1
0
mirror of https://github.com/square/okhttp.git synced 2025-08-07 12:42:57 +03:00

Fix race condition in RecordingHostnameVerifier

When connections are established concurrently, verify() sometimes throws a `java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 0` because of unsynchronized access to the `calls` list.
This commit is contained in:
Amir Livneh
2019-04-21 08:30:39 -04:00
parent cc7e3c8e99
commit 8deaef6702

View File

@@ -24,7 +24,7 @@ public final class RecordingHostnameVerifier implements HostnameVerifier {
public final List<String> calls = new ArrayList<>();
@Override
public boolean verify(String hostname, SSLSession session) {
public synchronized boolean verify(String hostname, SSLSession session) {
calls.add("verify " + hostname);
return true;
}