mirror of
https://github.com/square/okhttp.git
synced 2025-08-08 23:42:08 +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:
@@ -24,7 +24,7 @@ public final class RecordingHostnameVerifier implements HostnameVerifier {
|
|||||||
public final List<String> calls = new ArrayList<>();
|
public final List<String> calls = new ArrayList<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean verify(String hostname, SSLSession session) {
|
public synchronized boolean verify(String hostname, SSLSession session) {
|
||||||
calls.add("verify " + hostname);
|
calls.add("verify " + hostname);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user