Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Commit

Permalink
bugfix: unsynchronized iterator usage in getNextServer was not thread…
Browse files Browse the repository at this point in the history
… safe.
  • Loading branch information
kramer committed Mar 31, 2015
1 parent bc3178a commit e67f6ab
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,10 @@ public void shutdownClient() {
*/
protected String getNextServer() {
Iterator<String> iterator = serverPoolReference.get().getValue();
if (iterator.hasNext()) return iterator.next();
else throw new NoServerConfiguredException("No Server is assigned to client to connect");
synchronized (iterator) {
if (iterator.hasNext()) return iterator.next();
else throw new NoServerConfiguredException("No Server is assigned to client to connect");
}
}

protected int getServerPoolSize() {
Expand Down

0 comments on commit e67f6ab

Please sign in to comment.