[libpostgresql-jdbc-java] 16/22: PoolingDataSources were not picking up all of the properties that were set for them. Notably it would not give you a SSL connection when asked. It was copying individual properties over piecemeal and this got out of date as new properties were added to the BaseDataSource, but not added to the copying code. Use the existing serialization code to ensure that we really do copy all of the properties over.

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


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

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

commit ae402c234012736ce959aeaad9253105a57b4652
Author: Kris Jurka <books at ejurka.com>
Date:   Sat May 1 15:43:48 2010 +0000

    PoolingDataSources were not picking up all of the properties that
    were set for them.  Notably it would not give you a SSL connection
    when asked.  It was copying individual properties over piecemeal
    and this got out of date as new properties were added to the
    BaseDataSource, but not added to the copying code.  Use the
    existing serialization code to ensure that we really do copy all
    of the properties over.
    
    Backpatch back to 8.2 as earlier versions don't have many of these
    properties and the code has diverged.
    
    Per report by Eric Jain.
---
 org/postgresql/ds/common/BaseDataSource.java          | 19 +++++++++++++++----
 .../ds/jdbc23/AbstractJdbc23PoolingDataSource.java    | 15 +++++++++------
 2 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/org/postgresql/ds/common/BaseDataSource.java b/org/postgresql/ds/common/BaseDataSource.java
index 5386716..5db0052 100644
--- a/org/postgresql/ds/common/BaseDataSource.java
+++ b/org/postgresql/ds/common/BaseDataSource.java
@@ -3,19 +3,21 @@
 * Copyright (c) 2004-2008, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
-*   $PostgreSQL: pgjdbc/org/postgresql/ds/common/BaseDataSource.java,v 1.16 2009/06/20 14:51:59 jurka Exp $
+*   $PostgreSQL: pgjdbc/org/postgresql/ds/common/BaseDataSource.java,v 1.17 2009/06/20 15:19:40 jurka Exp $
 *
 *-------------------------------------------------------------------------
 */
 package org.postgresql.ds.common;
 
 import javax.naming.*;
-import java.io.PrintWriter;
 import java.sql.*;
 
-import java.io.ObjectOutputStream;
-import java.io.ObjectInputStream;
 import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 
 /**
  * Base class for data sources and related classes.
@@ -463,4 +465,13 @@ public abstract class BaseDataSource implements Referenceable
         compatible = (String)in.readObject();
     }
 
+    public void initializeFrom(BaseDataSource source) throws IOException, ClassNotFoundException {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ObjectOutputStream oos = new ObjectOutputStream(baos);
+        source.writeBaseObject(oos);
+        ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+        ObjectInputStream ois = new ObjectInputStream(bais);
+        readBaseObject(ois);
+    }
+
 }
diff --git a/org/postgresql/ds/jdbc23/AbstractJdbc23PoolingDataSource.java b/org/postgresql/ds/jdbc23/AbstractJdbc23PoolingDataSource.java
index 686c2e5..bbcda09 100644
--- a/org/postgresql/ds/jdbc23/AbstractJdbc23PoolingDataSource.java
+++ b/org/postgresql/ds/jdbc23/AbstractJdbc23PoolingDataSource.java
@@ -3,7 +3,7 @@
 * Copyright (c) 2004-2008, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
-*   $PostgreSQL: pgjdbc/org/postgresql/ds/jdbc23/AbstractJdbc23PoolingDataSource.java,v 1.1 2006/11/29 04:03:48 jurka Exp $
+*   $PostgreSQL: pgjdbc/org/postgresql/ds/jdbc23/AbstractJdbc23PoolingDataSource.java,v 1.2 2008/01/08 06:56:27 jurka Exp $
 *
 *-------------------------------------------------------------------------
 */
@@ -287,15 +287,18 @@ public abstract class AbstractJdbc23PoolingDataSource extends BaseDataSource
         synchronized (lock )
         {
             source = createConnectionPool();
-            source.setDatabaseName(getDatabaseName());
-            source.setPassword(getPassword());
-            source.setPortNumber(getPortNumber());
-            source.setServerName(getServerName());
-            source.setUser(getUser());
+            try {
+                source.initializeFrom(this);
+            } catch (Exception e) {
+                throw new PSQLException(GT.tr("Failed to setup DataSource."),
+                                        PSQLState.UNEXPECTED_ERROR, e);
+            }
+
             while (available.size() < initialConnections)
             {
                 available.push(source.getPooledConnection());
             }
+
             initialized = true;
         }
     }

-- 
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