Fixed race condition with addressList
@@ -2705,6 +2705,7 @@ final class SocketFinder {
*/
private InetSocketAddress getInetAddressByIPPreference(String hostName,
int portNumber) throws IOException, SQLServerException {
+ synchronized (addressList) {
InetSocketAddress addr = InetSocketAddress.createUnresolved(hostName, portNumber);
for (int i = 0; i < addressList.size(); i++) {
addr = new InetSocketAddress(addressList.get(i), portNumber);
@@ -2713,6 +2714,7 @@ final class SocketFinder {
}
return addr;
}
+ }
/**
* This method makes a connected socket given a hostname or IP address.
@@ -2794,6 +2796,7 @@ final class SocketFinder {
* Boolean switch for IPv6 first
*/
private void fillAddressList(InetAddress[] addresses, boolean ipv6first) {
+ synchronized (addressList) {
addressList.clear();
if (ipv6first) {
for (InetAddress addr : addresses) {
@@ -2809,6 +2812,7 @@ final class SocketFinder {
}
}
}
+ }
private Socket getConnectedSocket(InetAddress inetAddr, int portNumber,
int timeoutInMilliSeconds) throws IOException {
