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:
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user