Permalink
Browse files

feat: connect the socket only if the socket factory created an unconn…

…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 Jun 20, 2016
1 parent ee4c426 commit f75572beb8b59a7a73f6e1d12d692b483dc04c85
Showing with 3 additions and 1 deletion.
  1. +3 −1 pgjdbc/src/main/java/org/postgresql/core/PGStream.java
@@ -58,7 +58,9 @@ public PGStream(SocketFactory socketFactory, HostSpec hostSpec, int timeout) thr
this.hostSpec = hostSpec;
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);
setEncoding(Encoding.getJVMEncoding("UTF-8"));

0 comments on commit f75572b

Please sign in to comment.