[libpostgresql-jdbc-java] 11/128: Fix performance regresssion introduced by using InetSocketAddress getHostName() Patch provided by Scott Harrington, improved upon by Kris Jurka

Emmanuel Bourg ebourg-guest at moszumanska.debian.org
Mon Jan 9 10:18:25 UTC 2017


This is an automated email from the git hooks/post-receive script.

ebourg-guest pushed a commit to annotated tag REL9_3_1100
in repository libpostgresql-jdbc-java.

commit 066ae79fb7ca1f18f127976f3c55fe8ca17481ae
Author: Dave Cramer <davecramer at gmail.com>
Date:   Wed Oct 31 10:38:56 2012 -0400

    Fix performance regresssion introduced by using InetSocketAddress
    getHostName()
    Patch provided by Scott Harrington, improved upon by Kris Jurka
---
 org/postgresql/Driver.java.in                      | 14 +++++++-------
 org/postgresql/core/ConnectionFactory.java         | 14 ++++++--------
 org/postgresql/core/PGStream.java                  | 16 ++++++++--------
 org/postgresql/core/ProtocolConnection.java        |  6 +++---
 org/postgresql/core/v2/ConnectionFactoryImpl.java  | 20 ++++++++++----------
 org/postgresql/core/v2/ProtocolConnectionImpl.java |  8 ++++----
 org/postgresql/core/v3/ConnectionFactoryImpl.java  | 22 +++++++++++-----------
 org/postgresql/core/v3/ProtocolConnectionImpl.java |  8 ++++----
 org/postgresql/jdbc2/AbstractJdbc2Connection.java  | 12 ++++--------
 org/postgresql/jdbc3/AbstractJdbc3Connection.java  |  6 +++---
 org/postgresql/jdbc3/Jdbc3Connection.java          |  7 ++++---
 .../jdbc3g/AbstractJdbc3gConnection.java           |  6 +++---
 org/postgresql/jdbc3g/Jdbc3gConnection.java        |  7 ++++---
 org/postgresql/jdbc4/AbstractJdbc4Connection.java  |  6 +++---
 org/postgresql/jdbc4/Jdbc4Connection.java          |  7 ++++---
 org/postgresql/ssl/jdbc3/AbstractJdbc3MakeSSL.java |  2 +-
 org/postgresql/ssl/jdbc4/AbstractJdbc4MakeSSL.java | 10 +++++-----
 17 files changed, 84 insertions(+), 87 deletions(-)

diff --git a/org/postgresql/Driver.java.in b/org/postgresql/Driver.java.in
index 76e0800..f6c69c0 100644
--- a/org/postgresql/Driver.java.in
+++ b/org/postgresql/Driver.java.in
@@ -10,7 +10,6 @@ package org.postgresql;
 import java.io.*;
 import java.sql.*;
 import java.util.*;
-import java.net.InetSocketAddress;
 import java.net.URL;
 
 import java.security.AccessController;
@@ -21,6 +20,7 @@ import org.postgresql.util.PSQLException;
 import org.postgresql.util.PSQLState;
 import org.postgresql.util.PSQLDriverVersion;
 import org.postgresql.util.GT;
+import org.postgresql.util.HostSpec;
 
 import org.postgresql.core.Logger;
 
@@ -390,7 +390,7 @@ public class Driver implements java.sql.Driver
      * @throws SQLException if the connection could not be made
      */
     private static Connection makeConnection(String url, Properties props) throws SQLException {
-        return new @JDBCCONNECTCLASS@(address(props),
+        return new @JDBCCONNECTCLASS@(hostSpecs(props),
                                       user(props), database(props),
                                       props, url);
     }
@@ -647,15 +647,15 @@ public class Driver implements java.sql.Driver
     /**
      * @return the address portion of the URL
      */
-    private static InetSocketAddress[] address(Properties props)
+    private static HostSpec[] hostSpecs(Properties props)
     {
         String[] hosts = props.getProperty("PGHOST").split(",");
         String[] ports = props.getProperty("PGPORT").split(",");
-        InetSocketAddress[] addresses = new InetSocketAddress[hosts.length];
-        for (int i = 0; i < addresses.length; ++i) {
-            addresses[i] = new InetSocketAddress(hosts[i], Integer.parseInt(ports[i]));
+        HostSpec[] hostSpecs = new HostSpec[hosts.length];
+        for (int i = 0; i < hostSpecs.length; ++i) {
+            hostSpecs[i] = new HostSpec(hosts[i], Integer.parseInt(ports[i]));
         }
-        return addresses;
+        return hostSpecs;
     }
 
     /**
diff --git a/org/postgresql/core/ConnectionFactory.java b/org/postgresql/core/ConnectionFactory.java
index 569d599..a351619 100644
--- a/org/postgresql/core/ConnectionFactory.java
+++ b/org/postgresql/core/ConnectionFactory.java
@@ -8,10 +8,10 @@
 */
 package org.postgresql.core;
 
-import java.net.InetSocketAddress;
 import java.util.Properties;
 import java.sql.SQLException;
 
+import org.postgresql.util.HostSpec;
 import org.postgresql.util.PSQLException;
 import org.postgresql.util.GT;
 import org.postgresql.util.PSQLState;
@@ -42,8 +42,7 @@ public abstract class ConnectionFactory {
      *<p>
      * Currently, protocol versions 3 (7.4+) and 2 (pre-7.4) are supported.
      *
-     * @param host the host to connect to
-     * @param port the port to connect to
+     * @param hostSpecs at least one host and port to connect to; multiple elements for round-robin failover
      * @param user the username to authenticate with; may not be null.
      * @param database the database on the server to connect to; may not be null.
      * @param info extra properties controlling the connection;
@@ -52,7 +51,7 @@ public abstract class ConnectionFactory {
      * @return the new, initialized, connection
      * @throws SQLException if the connection could not be established.
      */
-    public static ProtocolConnection openConnection(InetSocketAddress[] address, String user, String database, Properties info, Logger logger) throws SQLException {
+    public static ProtocolConnection openConnection(HostSpec[] hostSpecs, String user, String database, Properties info, Logger logger) throws SQLException {
         String protoName = info.getProperty("protocolVersion");
 
         for (int i = 0; i < versions.length; ++i)
@@ -62,7 +61,7 @@ public abstract class ConnectionFactory {
                 continue;
 
             ConnectionFactory factory = (ConnectionFactory) versions[i][1];
-            ProtocolConnection connection = factory.openConnectionImpl(address, user, database, info, logger);
+            ProtocolConnection connection = factory.openConnectionImpl(hostSpecs, user, database, info, logger);
             if (connection != null)
                 return connection;
         }
@@ -75,8 +74,7 @@ public abstract class ConnectionFactory {
      * Implementation of {@link #openConnection} for a particular protocol version.
      * Implemented by subclasses of {@link ConnectionFactory}.
      *
-     * @param host the host to connect to
-     * @param port the port to connect to
+     * @param hostSpecs at least one host and port to connect to; multiple elements for round-robin failover
      * @param user the username to authenticate with; may not be null.
      * @param database the database on the server to connect to; may not be null.
      * @param info extra properties controlling the connection;
@@ -87,5 +85,5 @@ public abstract class ConnectionFactory {
      * @throws SQLException if the connection could not be established for a reason other
      *    than protocol version incompatibility.
      */
-    public abstract ProtocolConnection openConnectionImpl(InetSocketAddress[] address, String user, String database, Properties info, Logger logger) throws SQLException;
+    public abstract ProtocolConnection openConnectionImpl(HostSpec[] hostSpecs, String user, String database, Properties info, Logger logger) throws SQLException;
 }
diff --git a/org/postgresql/core/PGStream.java b/org/postgresql/core/PGStream.java
index 3c75ee5..fad4c12 100644
--- a/org/postgresql/core/PGStream.java
+++ b/org/postgresql/core/PGStream.java
@@ -19,6 +19,7 @@ import java.net.Socket;
 import java.sql.SQLException;
 
 import org.postgresql.util.GT;
+import org.postgresql.util.HostSpec;
 import org.postgresql.util.PSQLState;
 import org.postgresql.util.PSQLException;
 
@@ -31,7 +32,7 @@ import org.postgresql.util.PSQLException;
  */
 public class PGStream
 {
-    private final InetSocketAddress address;
+    private final HostSpec hostSpec;
 
     private final byte[] _int4buf;
     private final byte[] _int2buf;
@@ -48,16 +49,15 @@ public class PGStream
      * Constructor:  Connect to the PostgreSQL back end and return
      * a stream connection.
      *
-     * @param host the hostname to connect to
-     * @param port the port number that the postmaster is sitting on
+     * @param hostSpec the host and port to connect to
      * @exception IOException if an IOException occurs below it.
      */
-    public PGStream(InetSocketAddress address) throws IOException
+    public PGStream(HostSpec hostSpec) throws IOException
     {
-        this.address = address;
+        this.hostSpec = hostSpec;
 
         Socket socket = new Socket();
-        socket.connect(address);
+        socket.connect(new InetSocketAddress(hostSpec.getHost(), hostSpec.getPort()));
         changeSocket(socket);
         setEncoding(Encoding.getJVMEncoding("US-ASCII"));
 
@@ -65,8 +65,8 @@ public class PGStream
         _int4buf = new byte[4];
     }
 
-    public InetSocketAddress getAddress() {
-        return address;
+    public HostSpec getHostSpec() {
+        return hostSpec;
     }
 
     public Socket getSocket() {
diff --git a/org/postgresql/core/ProtocolConnection.java b/org/postgresql/core/ProtocolConnection.java
index 153c277..62c0f1b 100644
--- a/org/postgresql/core/ProtocolConnection.java
+++ b/org/postgresql/core/ProtocolConnection.java
@@ -9,8 +9,8 @@
 package org.postgresql.core;
 
 import org.postgresql.PGNotification;
+import org.postgresql.util.HostSpec;
 
-import java.net.InetSocketAddress;
 import java.sql.*;
 import java.util.Set;
 
@@ -40,9 +40,9 @@ public interface ProtocolConnection {
     static final int TRANSACTION_FAILED = 2;
 
     /**
-     * @return the address this connection is connected to.
+     * @return the host and port this connection is connected to.
      */
-    InetSocketAddress getAddress();
+    HostSpec getHostSpec();
 
     /**
      * @return the user this connection authenticated as.
diff --git a/org/postgresql/core/v2/ConnectionFactoryImpl.java b/org/postgresql/core/v2/ConnectionFactoryImpl.java
index 90523a1..a0cfc96 100644
--- a/org/postgresql/core/v2/ConnectionFactoryImpl.java
+++ b/org/postgresql/core/v2/ConnectionFactoryImpl.java
@@ -15,7 +15,6 @@ import java.sql.SQLException;
 import java.sql.SQLWarning;
 import java.io.IOException;
 import java.net.ConnectException;
-import java.net.InetSocketAddress;
 
 import org.postgresql.core.*;
 import org.postgresql.util.PSQLException;
@@ -23,6 +22,7 @@ import org.postgresql.util.PSQLState;
 import org.postgresql.util.UnixCrypt;
 import org.postgresql.util.MD5Digest;
 import org.postgresql.util.GT;
+import org.postgresql.util.HostSpec;
 
 /**
  * ConnectionFactory implementation for version 2 (pre-7.4) connections.
@@ -38,7 +38,7 @@ public class ConnectionFactoryImpl extends ConnectionFactory {
     private static final int AUTH_REQ_MD5 = 5;
     private static final int AUTH_REQ_SCM = 6;
 
-    public ProtocolConnection openConnectionImpl(InetSocketAddress[] addresses, String user, String database, Properties info, Logger logger) throws SQLException {
+    public ProtocolConnection openConnectionImpl(HostSpec[] hostSpecs, String user, String database, Properties info, Logger logger) throws SQLException {
         // Extract interesting values from the info properties:
         //  - the SSL setting
         boolean requireSSL;
@@ -70,10 +70,10 @@ public class ConnectionFactoryImpl extends ConnectionFactory {
         //  - the TCP keep alive setting
         boolean requireTCPKeepAlive = (Boolean.valueOf(info.getProperty("tcpKeepAlive")).booleanValue());
 
-        for (int addr = 0; addr < addresses.length; ++addr) {
-            InetSocketAddress address = addresses[addr];
+        for (int whichHost = 0; whichHost < hostSpecs.length; ++whichHost) {
+            HostSpec hostSpec = hostSpecs[whichHost];
             if (logger.logDebug())
-                logger.debug("Trying to establish a protocol version 2 connection to " + address);
+                logger.debug("Trying to establish a protocol version 2 connection to " + hostSpec);
 
             //
             // Establish a connection.
@@ -83,7 +83,7 @@ public class ConnectionFactoryImpl extends ConnectionFactory {
         PGStream newStream = null;
         try
         {
-            newStream = new PGStream(address);
+            newStream = new PGStream(hostSpec);
 
             // Construct and send an ssl startup packet if requested.
             if (trySSL)
@@ -127,7 +127,7 @@ public class ConnectionFactoryImpl extends ConnectionFactory {
             // ConnectException is thrown when the connection cannot be made.
             // we trap this an return a more meaningful message for the end user
 
-            if (addr+1 < addresses.length) {
+            if (whichHost + 1 < hostSpecs.length) {
                 // still more addresses to try
                 continue;
             }
@@ -146,7 +146,7 @@ public class ConnectionFactoryImpl extends ConnectionFactory {
                 }
             }
 
-            if (addr+1 < addresses.length) {
+            if (whichHost + 1 < hostSpecs.length) {
                 // still more addresses to try
                 continue;
             }
@@ -165,7 +165,7 @@ public class ConnectionFactoryImpl extends ConnectionFactory {
                 }
             }
 
-            if (addr+1 < addresses.length) {
+            if (whichHost + 1 < hostSpecs.length) {
                 // still more addresses to try
                 continue;
             }
@@ -199,7 +199,7 @@ public class ConnectionFactoryImpl extends ConnectionFactory {
 
             // We have to reconnect to continue.
             pgStream.close();
-            return new PGStream(pgStream.getAddress());
+            return new PGStream(pgStream.getHostSpec());
 
         case 'N':
             if (logger.logDebug())
diff --git a/org/postgresql/core/v2/ProtocolConnectionImpl.java b/org/postgresql/core/v2/ProtocolConnectionImpl.java
index 567ad3e..204ad9f 100644
--- a/org/postgresql/core/v2/ProtocolConnectionImpl.java
+++ b/org/postgresql/core/v2/ProtocolConnectionImpl.java
@@ -11,12 +11,12 @@ package org.postgresql.core.v2;
 import java.sql.SQLException;
 import java.sql.SQLWarning;
 import java.io.IOException;
-import java.net.InetSocketAddress;
 import java.util.ArrayList;
 import java.util.Set;
 
 import org.postgresql.PGNotification;
 import org.postgresql.core.*;
+import org.postgresql.util.HostSpec;
 
 /**
  * V2 implementation of ProtocolConnection.
@@ -32,8 +32,8 @@ class ProtocolConnectionImpl implements ProtocolConnection {
         this.executor = new QueryExecutorImpl(this, pgStream, logger);
     }
 
-    public InetSocketAddress getAddress() {
-        return pgStream.getAddress();
+    public HostSpec getHostSpec() {
+        return pgStream.getHostSpec();
     }
 
     public String getUser() {
@@ -87,7 +87,7 @@ class ProtocolConnectionImpl implements ProtocolConnection {
             if (logger.logDebug())
                 logger.debug(" FE=> CancelRequest(pid=" + cancelPid + ",ckey=" + cancelKey + ")");
 
-            cancelStream = new PGStream(pgStream.getAddress());
+            cancelStream = new PGStream(pgStream.getHostSpec());
             cancelStream.SendInteger4(16);
             cancelStream.SendInteger2(1234);
             cancelStream.SendInteger2(5678);
diff --git a/org/postgresql/core/v3/ConnectionFactoryImpl.java b/org/postgresql/core/v3/ConnectionFactoryImpl.java
index d50c07d..95eaa43 100644
--- a/org/postgresql/core/v3/ConnectionFactoryImpl.java
+++ b/org/postgresql/core/v3/ConnectionFactoryImpl.java
@@ -14,7 +14,6 @@ import java.util.TimeZone;
 import java.sql.SQLException;
 import java.io.IOException;
 import java.net.ConnectException;
-import java.net.InetSocketAddress;
 
 import org.postgresql.core.*;
 import org.postgresql.util.PSQLException;
@@ -24,6 +23,7 @@ import org.postgresql.util.ServerErrorMessage;
 import org.postgresql.util.UnixCrypt;
 import org.postgresql.util.MD5Digest;
 import org.postgresql.util.GT;
+import org.postgresql.util.HostSpec;
 
 /**
  * ConnectionFactory implementation for version 3 (7.4+) connections.
@@ -46,7 +46,7 @@ public class ConnectionFactoryImpl extends ConnectionFactory {
     private static class UnsupportedProtocolException extends IOException {
     }
 
-    public ProtocolConnection openConnectionImpl(InetSocketAddress[] addresses, String user, String database, Properties info, Logger logger) throws SQLException {
+    public ProtocolConnection openConnectionImpl(HostSpec[] hostSpecs, String user, String database, Properties info, Logger logger) throws SQLException {
         // Extract interesting values from the info properties:
         //  - the SSL setting
         boolean requireSSL;
@@ -85,11 +85,11 @@ public class ConnectionFactoryImpl extends ConnectionFactory {
         //
         // Change by Chris Smith <cdsmith at twu.net>
 
-        for (int addr = 0; addr < addresses.length; ++addr) {
-            InetSocketAddress address = addresses[addr];
+        for (int whichHost = 0; whichHost < hostSpecs.length; ++whichHost) {
+            HostSpec hostSpec = hostSpecs[whichHost];
             
         if (logger.logDebug())
-            logger.debug("Trying to establish a protocol version 3 connection to " + address);
+            logger.debug("Trying to establish a protocol version 3 connection to " + hostSpec);
 
         //
         // Establish a connection.
@@ -98,7 +98,7 @@ public class ConnectionFactoryImpl extends ConnectionFactory {
         PGStream newStream = null;
         try
         {
-            newStream = new PGStream(address);
+            newStream = new PGStream(hostSpec);
 
             // Construct and send an ssl startup packet if requested.
             if (trySSL)
@@ -170,7 +170,7 @@ public class ConnectionFactoryImpl extends ConnectionFactory {
             sendStartupPacket(newStream, params, logger);
 
             // Do authentication (until AuthenticationOk).
-            doAuthentication(newStream, address.getHostName(), user, info, logger);
+            doAuthentication(newStream, hostSpec.getHost(), user, info, logger);
 
             // Do final startup.
             ProtocolConnectionImpl protoConnection = new ProtocolConnectionImpl(newStream, user, database, info, logger);
@@ -200,7 +200,7 @@ public class ConnectionFactoryImpl extends ConnectionFactory {
             // Added by Peter Mount <peter at retep.org.uk>
             // ConnectException is thrown when the connection cannot be made.
             // we trap this an return a more meaningful message for the end user
-            if (addr+1 < addresses.length) {
+            if (whichHost + 1 < hostSpecs.length) {
                 // still more addresses to try
                 continue;
             }
@@ -218,7 +218,7 @@ public class ConnectionFactoryImpl extends ConnectionFactory {
                 {
                 }
             }
-            if (addr+1 < addresses.length) {
+            if (whichHost + 1 < hostSpecs.length) {
                 // still more addresses to try
                 continue;
             }
@@ -236,7 +236,7 @@ public class ConnectionFactoryImpl extends ConnectionFactory {
                 {
                 }
             }
-            if (addr+1 < addresses.length) {
+            if (whichHost + 1 < hostSpecs.length) {
                 // still more addresses to try
                 continue;
             }
@@ -296,7 +296,7 @@ public class ConnectionFactoryImpl extends ConnectionFactory {
 
             // We have to reconnect to continue.
             pgStream.close();
-            return new PGStream(pgStream.getAddress());
+            return new PGStream(pgStream.getHostSpec());
 
         case 'N':
             if (logger.logDebug())
diff --git a/org/postgresql/core/v3/ProtocolConnectionImpl.java b/org/postgresql/core/v3/ProtocolConnectionImpl.java
index 94214b4..6c40204 100644
--- a/org/postgresql/core/v3/ProtocolConnectionImpl.java
+++ b/org/postgresql/core/v3/ProtocolConnectionImpl.java
@@ -10,11 +10,11 @@ package org.postgresql.core.v3;
 
 import org.postgresql.PGNotification;
 import org.postgresql.core.*;
+import org.postgresql.util.HostSpec;
 
 import java.sql.SQLException;
 import java.sql.SQLWarning;
 import java.io.IOException;
-import java.net.InetSocketAddress;
 import java.util.ArrayList;
 import java.util.Set;
 import java.util.HashSet;
@@ -37,8 +37,8 @@ class ProtocolConnectionImpl implements ProtocolConnection {
         this.standardConformingStrings = false;
     }
 
-    public InetSocketAddress getAddress() {
-        return pgStream.getAddress();
+    public HostSpec getHostSpec() {
+        return pgStream.getHostSpec();
     }
 
     public String getUser() {
@@ -89,7 +89,7 @@ class ProtocolConnectionImpl implements ProtocolConnection {
             if (logger.logDebug())
                 logger.debug(" FE=> CancelRequest(pid=" + cancelPid + ",ckey=" + cancelKey + ")");
 
-            cancelStream = new PGStream(pgStream.getAddress());
+            cancelStream = new PGStream(pgStream.getHostSpec());
             cancelStream.SendInteger4(16);
             cancelStream.SendInteger2(1234);
             cancelStream.SendInteger2(5678);
diff --git a/org/postgresql/jdbc2/AbstractJdbc2Connection.java b/org/postgresql/jdbc2/AbstractJdbc2Connection.java
index d5e38c1..2fb37f4 100644
--- a/org/postgresql/jdbc2/AbstractJdbc2Connection.java
+++ b/org/postgresql/jdbc2/AbstractJdbc2Connection.java
@@ -13,17 +13,13 @@ import java.sql.*;
 import java.util.*;
 
 import org.postgresql.core.*;
-import java.net.InetSocketAddress;
 
 import org.postgresql.Driver;
 import org.postgresql.PGNotification;
 import org.postgresql.fastpath.Fastpath;
 import org.postgresql.largeobject.LargeObjectManager;
-import org.postgresql.util.PGBinaryObject;
-import org.postgresql.util.PSQLState;
-import org.postgresql.util.PGobject;
-import org.postgresql.util.PSQLException;
-import org.postgresql.util.GT;
+import org.postgresql.util.*;
+import org.postgresql.util.HostSpec;
 import org.postgresql.copy.*;
 
 /**
@@ -86,7 +82,7 @@ public abstract class AbstractJdbc2Connection implements BaseConnection
     //
     // Ctor.
     //
-    protected AbstractJdbc2Connection(InetSocketAddress[] address, String user, String database, Properties info, String url) throws SQLException
+    protected AbstractJdbc2Connection(HostSpec[] hostSpecs, String user, String database, Properties info, String url) throws SQLException
     {
         this.creatingURL = url;
 
@@ -137,7 +133,7 @@ public abstract class AbstractJdbc2Connection implements BaseConnection
             logger.info(Driver.getVersion());
 
         // Now make the initial connection and set up local state
-        this.protoConnection = ConnectionFactory.openConnection(address, user, database, info, logger);
+        this.protoConnection = ConnectionFactory.openConnection(hostSpecs, user, database, info, logger);
         this.dbVersionNumber = protoConnection.getServerVersion();
         this.compatible = info.getProperty("compatible", Driver.MAJORVERSION + "." + Driver.MINORVERSION);
 
diff --git a/org/postgresql/jdbc3/AbstractJdbc3Connection.java b/org/postgresql/jdbc3/AbstractJdbc3Connection.java
index da11958..c7738a0 100644
--- a/org/postgresql/jdbc3/AbstractJdbc3Connection.java
+++ b/org/postgresql/jdbc3/AbstractJdbc3Connection.java
@@ -7,10 +7,10 @@
 */
 package org.postgresql.jdbc3;
 
-import java.net.InetSocketAddress;
 import java.util.Properties;
 import java.sql.*;
 
+import org.postgresql.util.HostSpec;
 import org.postgresql.util.PSQLException;
 import org.postgresql.util.PSQLState;
 import org.postgresql.util.GT;
@@ -25,8 +25,8 @@ public abstract class AbstractJdbc3Connection extends org.postgresql.jdbc2.Abstr
     private int rsHoldability = ResultSet.CLOSE_CURSORS_AT_COMMIT;
     private int savepointId = 0;
 
-    protected AbstractJdbc3Connection(InetSocketAddress[] address, String user, String database, Properties info, String url) throws SQLException {
-        super(address, user, database, info, url);
+    protected AbstractJdbc3Connection(HostSpec[] hostSpec, String user, String database, Properties info, String url) throws SQLException {
+        super(hostSpec, user, database, info, url);
     }
 
     /**
diff --git a/org/postgresql/jdbc3/Jdbc3Connection.java b/org/postgresql/jdbc3/Jdbc3Connection.java
index 7be70fb..470f04c 100644
--- a/org/postgresql/jdbc3/Jdbc3Connection.java
+++ b/org/postgresql/jdbc3/Jdbc3Connection.java
@@ -7,11 +7,12 @@
 */
 package org.postgresql.jdbc3;
 
-import java.net.InetSocketAddress;
 import java.util.Map;
 import java.util.Properties;
 import java.sql.SQLException;
 
+import org.postgresql.util.HostSpec;
+
 /**
  * This class implements the java.sql.Connection interface for JDBC3.
  * However most of the implementation is really done in
@@ -19,8 +20,8 @@ import java.sql.SQLException;
  */
 public class Jdbc3Connection extends org.postgresql.jdbc3.AbstractJdbc3Connection implements java.sql.Connection
 {
-    public Jdbc3Connection(InetSocketAddress[] address,, String user, String database, Properties info, String url) throws SQLException {
-        super(address, user, database, info, url);
+    public Jdbc3Connection(HostSpec[] hostSpecs,, String user, String database, Properties info, String url) throws SQLException {
+        super(hostSpecs, user, database, info, url);
     }
 
     public java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
diff --git a/org/postgresql/jdbc3g/AbstractJdbc3gConnection.java b/org/postgresql/jdbc3g/AbstractJdbc3gConnection.java
index 61e58b6..1b42c33 100644
--- a/org/postgresql/jdbc3g/AbstractJdbc3gConnection.java
+++ b/org/postgresql/jdbc3g/AbstractJdbc3gConnection.java
@@ -7,18 +7,18 @@
 */
 package org.postgresql.jdbc3g;
 
-import java.net.InetSocketAddress;
 import java.sql.SQLException;
 import java.util.Properties;
 
 import org.postgresql.core.Oid;
 import org.postgresql.core.TypeInfo;
+import org.postgresql.util.HostSpec;
 
 public abstract class AbstractJdbc3gConnection extends org.postgresql.jdbc3.AbstractJdbc3Connection
 {
 
-    public AbstractJdbc3gConnection(InetSocketAddress[] address, String user, String database, Properties info, String url) throws SQLException {
-        super(address, user, database, info, url);
+    public AbstractJdbc3gConnection(HostSpec[] hostSpecs, String user, String database, Properties info, String url) throws SQLException {
+        super(hostSpecs, user, database, info, url);
 
         TypeInfo types = getTypeInfo();
         if (haveMinimumServerVersion("8.3")) {
diff --git a/org/postgresql/jdbc3g/Jdbc3gConnection.java b/org/postgresql/jdbc3g/Jdbc3gConnection.java
index 4ff2dbc..b8dfe00 100644
--- a/org/postgresql/jdbc3g/Jdbc3gConnection.java
+++ b/org/postgresql/jdbc3g/Jdbc3gConnection.java
@@ -7,11 +7,12 @@
 */
 package org.postgresql.jdbc3g;
 
-import java.net.InetSocketAddress;
 import java.util.Map;
 import java.util.Properties;
 import java.sql.SQLException;
 
+import org.postgresql.util.HostSpec;
+
 /**
  * This class implements the java.sql.Connection interface for JDBC3.
  * However most of the implementation is really done in
@@ -19,8 +20,8 @@ import java.sql.SQLException;
  */
 public class Jdbc3gConnection extends org.postgresql.jdbc3g.AbstractJdbc3gConnection implements java.sql.Connection
 {
-    public Jdbc3gConnection(InetSocketAddress[] address, String user, String database, Properties info, String url) throws SQLException {
-        super(address, user, database, info, url);
+    public Jdbc3gConnection(HostSpec[] hostSpecs, String user, String database, Properties info, String url) throws SQLException {
+        super(hostSpecs, user, database, info, url);
     }
 
     public java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
diff --git a/org/postgresql/jdbc4/AbstractJdbc4Connection.java b/org/postgresql/jdbc4/AbstractJdbc4Connection.java
index 444a582..8a89a80 100644
--- a/org/postgresql/jdbc4/AbstractJdbc4Connection.java
+++ b/org/postgresql/jdbc4/AbstractJdbc4Connection.java
@@ -7,7 +7,6 @@
 */
 package org.postgresql.jdbc4;
 
-import java.net.InetSocketAddress;
 import java.sql.*;
 import java.util.Map;
 import java.util.HashMap;
@@ -19,6 +18,7 @@ import org.postgresql.core.Oid;
 import org.postgresql.core.Utils;
 import org.postgresql.core.TypeInfo;
 import org.postgresql.util.GT;
+import org.postgresql.util.HostSpec;
 import org.postgresql.util.PSQLState;
 import org.postgresql.util.PSQLException;
 import org.postgresql.jdbc2.AbstractJdbc2Array;
@@ -27,8 +27,8 @@ abstract class AbstractJdbc4Connection extends org.postgresql.jdbc3g.AbstractJdb
 {
     private final Properties _clientInfo;
 
-    public AbstractJdbc4Connection(InetSocketAddress[] address, String user, String database, Properties info, String url) throws SQLException {
-        super(address, user, database, info, url);
+    public AbstractJdbc4Connection(HostSpec[] hostSpecs, String user, String database, Properties info, String url) throws SQLException {
+        super(hostSpecs, user, database, info, url);
 
         TypeInfo types = getTypeInfo();
         if (haveMinimumServerVersion("8.3")) {
diff --git a/org/postgresql/jdbc4/Jdbc4Connection.java b/org/postgresql/jdbc4/Jdbc4Connection.java
index 06fd289..209b970 100644
--- a/org/postgresql/jdbc4/Jdbc4Connection.java
+++ b/org/postgresql/jdbc4/Jdbc4Connection.java
@@ -7,11 +7,12 @@
 */
 package org.postgresql.jdbc4;
 
-import java.net.InetSocketAddress;
 import java.util.Map;
 import java.util.Properties;
 import java.sql.SQLException;
 
+import org.postgresql.util.HostSpec;
+
 /**
  * This class implements the java.sql.Connection interface for JDBC4.
  * However most of the implementation is really done in
@@ -19,8 +20,8 @@ import java.sql.SQLException;
  */
 public class Jdbc4Connection extends AbstractJdbc4Connection implements java.sql.Connection
 {
-    public Jdbc4Connection(InetSocketAddress[] address, String user, String database, Properties info, String url) throws SQLException {
-        super(address, user, database, info, url);
+    public Jdbc4Connection(HostSpec[] hostSpecs, String user, String database, Properties info, String url) throws SQLException {
+        super(hostSpecs, user, database, info, url);
     }
 
     public java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
diff --git a/org/postgresql/ssl/jdbc3/AbstractJdbc3MakeSSL.java b/org/postgresql/ssl/jdbc3/AbstractJdbc3MakeSSL.java
index b968f17..a5ae634 100644
--- a/org/postgresql/ssl/jdbc3/AbstractJdbc3MakeSSL.java
+++ b/org/postgresql/ssl/jdbc3/AbstractJdbc3MakeSSL.java
@@ -59,7 +59,7 @@ public class AbstractJdbc3MakeSSL {
             }
         }
 
-        Socket newConnection = factory.createSocket(stream.getSocket(), stream.getAddress().getHostName(), stream.getAddress().getPort(), true);
+        Socket newConnection = factory.createSocket(stream.getSocket(), stream.getHostSpec().getHost(), stream.getHostSpec().getPort(), true);
         stream.changeSocket(newConnection);
     }
 
diff --git a/org/postgresql/ssl/jdbc4/AbstractJdbc4MakeSSL.java b/org/postgresql/ssl/jdbc4/AbstractJdbc4MakeSSL.java
index aed726e..b4ebd89 100644
--- a/org/postgresql/ssl/jdbc4/AbstractJdbc4MakeSSL.java
+++ b/org/postgresql/ssl/jdbc4/AbstractJdbc4MakeSSL.java
@@ -114,7 +114,7 @@ public class AbstractJdbc4MakeSSL {
         SSLSocket newConnection;
         try
         {
-          newConnection = (SSLSocket)factory.createSocket(stream.getSocket(), stream.getAddress().getHostName(), stream.getAddress().getPort(), true);
+          newConnection = (SSLSocket)factory.createSocket(stream.getSocket(), stream.getHostSpec().getHost(), stream.getHostSpec().getPort(), true);
           newConnection.startHandshake(); //We must invoke manually, otherwise the exceptions are hidden
         }
         catch (IOException ex) {
@@ -137,16 +137,16 @@ public class AbstractJdbc4MakeSSL {
           {
               throw new PSQLException(GT.tr("The HostnameVerifier class provided {0} could not be instantiated.", sslhostnameverifier), PSQLState.CONNECTION_FAILURE, e);
           }
-          if (!hvn.verify(stream.getAddress().getHostName(), newConnection.getSession()))
+          if (!hvn.verify(stream.getHostSpec().getHost(), newConnection.getSession()))
           {
-            throw new PSQLException(GT.tr("The hostname {0} could not be verified by hostnameverifier {1}.", new Object[]{stream.getAddress().getHostName(), sslhostnameverifier}), PSQLState.CONNECTION_FAILURE);
+            throw new PSQLException(GT.tr("The hostname {0} could not be verified by hostnameverifier {1}.", new Object[]{stream.getHostSpec().getHost(), sslhostnameverifier}), PSQLState.CONNECTION_FAILURE);
           }
         } else {
           if ("verify-full".equals(sslmode) && factory instanceof LibPQFactory)
           {
-            if (!(((LibPQFactory)factory).verify(stream.getAddress().getHostName(), newConnection.getSession())))
+            if (!(((LibPQFactory)factory).verify(stream.getHostSpec().getHost(), newConnection.getSession())))
             {
-              throw new PSQLException(GT.tr("The hostname {0} could not be verified.", stream.getAddress().getHostName()), PSQLState.CONNECTION_FAILURE);
+              throw new PSQLException(GT.tr("The hostname {0} could not be verified.", stream.getHostSpec().getHost()), PSQLState.CONNECTION_FAILURE);
             }
           }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/libpostgresql-jdbc-java.git



More information about the pkg-java-commits mailing list