Skip to content

Commit 9076b4a

Browse files
committed
Fixed two NPEs.
1 parent 3e1306c commit 9076b4a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

network/common/src/main/java/org/apache/spark/network/client/TransportClientFactory.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ private class ClientPool {
6666
public ClientPool() {
6767
clients = new TransportClient[numConnectionsPerPeer];
6868
locks = new Object[numConnectionsPerPeer];
69+
for (int i = 0; i < numConnectionsPerPeer; i++) {
70+
locks[i] = new Object();
71+
}
6972
}
7073
}
7174

@@ -120,7 +123,8 @@ public TransportClient createClient(String remoteHost, int remotePort) throws IO
120123
// Create the ClientPool if we don't have it yet.
121124
ClientPool clientPool = connectionPool.get(address);
122125
if (clientPool == null) {
123-
clientPool = connectionPool.putIfAbsent(address, new ClientPool());
126+
connectionPool.putIfAbsent(address, new ClientPool());
127+
clientPool = connectionPool.get(address);
124128
}
125129

126130
int clientIndex = rand.nextInt(numConnectionsPerPeer);

0 commit comments

Comments
 (0)