Skip to content

Commit

Permalink
feat: connect the socket only if the socket factory created an unconn…
Browse files Browse the repository at this point in the history
…ected socket

This is useful if the socket factory creates the complete connection,
for example when using Unix sockets.

fixes #587
  • Loading branch information
trygvis authored and vlsi committed Nov 24, 2016
1 parent ee4c426 commit f75572b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pgjdbc/src/main/java/org/postgresql/core/PGStream.java
Expand Up @@ -58,7 +58,9 @@ public PGStream(SocketFactory socketFactory, HostSpec hostSpec, int timeout) thr
this.hostSpec = hostSpec; this.hostSpec = hostSpec;


Socket socket = socketFactory.createSocket(); Socket socket = socketFactory.createSocket();
socket.connect(new InetSocketAddress(hostSpec.getHost(), hostSpec.getPort()), timeout); if (!socket.isConnected()) {
socket.connect(new InetSocketAddress(hostSpec.getHost(), hostSpec.getPort()), timeout);
}
changeSocket(socket); changeSocket(socket);
setEncoding(Encoding.getJVMEncoding("UTF-8")); setEncoding(Encoding.getJVMEncoding("UTF-8"));


Expand Down

0 comments on commit f75572b

Please sign in to comment.