@@ -0,0 +1,1412 @@
+package org.testng.internal.remote;%0A%0Aimport java.io.IOException;%0Aimport java.net.Socket;%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0A%0Aimport org.testng.remote.ConnectionInfo;%0A%0A%0A/**%0A * This class maintains a pool of slaves (represented by sockets).%0A * %0A * @author cbeust%0A */%0Apublic class SlavePool %7B%0A  private static SocketLinkedBlockingQueue m_hosts = new SocketLinkedBlockingQueue();%0A  private static Map%3CSocket, ConnectionInfo%3E m_connectionInfos =%0A    new HashMap%3CSocket, ConnectionInfo%3E();%0A  %0A  public void addSlaves(Socket%5B%5D slaves) throws IOException %7B%0A    for (Socket s : slaves) %7B%0A      addSlave(s);%0A    %7D%0A  %7D%0A  %0A  public void addSlave(Socket s) %7B%0A    ConnectionInfo ci = new ConnectionInfo();%0A    ci.setSocket(s);%0A    addSlave(s, ci);%0A  %7D%0A  %0A  private void addSlave(Socket s, ConnectionInfo ci) %7B%0A    m_hosts.add(s);%0A    m_connectionInfos.put(s, ci);%0A  %7D%0A  %0A  public ConnectionInfo getSlave() %7B%0A    ConnectionInfo result = null;%0A    Socket host = null;%0A    %0A    try %7B%0A      host = m_hosts.take();%0A      result = m_connectionInfos.get(host);%0A    %7D%0A    catch (InterruptedException e) %7B%0A      e.printStackTrace();%0A    %7D%0A    %0A    return result;%0A  %7D%0A  %0A  public void returnSlave(ConnectionInfo slave) throws IOException %7B%0A    m_hosts.add(slave.getSocket());%0A//    ConnectionInfo ci = m_connectionInfos.remove(slave.socket);%0A//    ci.oos.close();%0A//    ci.ois.close();%0A//    addSlave(slave.socket);%0A  %7D%0A%0A%7D%0A

Factored out common code to JDK14 and JDK5+