commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r745532 - in /commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp: DelegatingConnection.java DelegatingResultSet.java DelegatingStatement.java cpdsadapter/ConnectionImpl.java
Date Wed, 18 Feb 2009 15:03:48 GMT
Author: markt
Date: Wed Feb 18 15:03:47 2009
New Revision: 745532

URL: http://svn.apache.org/viewvc?rev=745532&view=rev
Log:
Improved fix for DBCP-191. Use a wrapper implementation that matches JavaDoc.
Patch provided by J. David Beutel.

Modified:
    commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/DelegatingConnection.java
    commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/DelegatingResultSet.java
    commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/DelegatingStatement.java
    commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/cpdsadapter/ConnectionImpl.java

Modified: commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/DelegatingConnection.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/DelegatingConnection.java?rev=745532&r1=745531&r2=745532&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/DelegatingConnection.java (original)
+++ commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/DelegatingConnection.java Wed
Feb 18 15:03:47 2009
@@ -519,11 +519,17 @@
 /* JDBC_4_ANT_KEY_BEGIN */
 
     public boolean isWrapperFor(Class<?> iface) throws SQLException {
-        return _conn.isWrapperFor(iface);
+        return iface.isAssignableFrom(getClass()) || _conn.isWrapperFor(iface);
     }
 
     public <T> T unwrap(Class<T> iface) throws SQLException {
-        return _conn.unwrap(iface);
+        if (iface.isAssignableFrom(getClass())) {
+            return iface.cast(this);
+        } else if (iface.isAssignableFrom(_conn.getClass())) {
+            return iface.cast(_conn);
+        } else {
+            return _conn.unwrap(iface);
+        }
     }
 
     public Array createArrayOf(String typeName, Object[] elements) throws SQLException {

Modified: commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/DelegatingResultSet.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/DelegatingResultSet.java?rev=745532&r1=745531&r2=745532&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/DelegatingResultSet.java (original)
+++ commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/DelegatingResultSet.java Wed
Feb 18 15:03:47 2009
@@ -594,11 +594,17 @@
 /* JDBC_4_ANT_KEY_BEGIN */
 
     public boolean isWrapperFor(Class<?> iface) throws SQLException {
-        return _res.isWrapperFor(iface);
+        return iface.isAssignableFrom(getClass()) || _res.isWrapperFor(iface);
     }
 
     public <T> T unwrap(Class<T> iface) throws SQLException {
-        return _res.unwrap(iface);
+        if (iface.isAssignableFrom(getClass())) {
+            return iface.cast(this);
+        } else if (iface.isAssignableFrom(_res.getClass())) {
+            return iface.cast(_res);
+        } else {
+            return _res.unwrap(iface);
+        }
     }
 
     public RowId getRowId(int columnIndex) throws SQLException {

Modified: commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/DelegatingStatement.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/DelegatingStatement.java?rev=745532&r1=745531&r2=745532&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/DelegatingStatement.java (original)
+++ commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/DelegatingStatement.java Wed
Feb 18 15:03:47 2009
@@ -355,11 +355,17 @@
 /* JDBC_4_ANT_KEY_BEGIN */
 
     public boolean isWrapperFor(Class<?> iface) throws SQLException {
-        return _conn.isWrapperFor(iface);
+        return iface.isAssignableFrom(getClass()) || _conn.isWrapperFor(iface);
     }
 
     public <T> T unwrap(Class<T> iface) throws SQLException {
-        return _conn.unwrap(iface);
+        if (iface.isAssignableFrom(getClass())) {
+            return iface.cast(this);
+        } else if (iface.isAssignableFrom(_conn.getClass())) {
+            return iface.cast(_conn);
+        } else {
+            return _conn.unwrap(iface);
+        }
     }
 
     public void setPoolable(boolean poolable) throws SQLException {

Modified: commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/cpdsadapter/ConnectionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/cpdsadapter/ConnectionImpl.java?rev=745532&r1=745531&r2=745532&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/cpdsadapter/ConnectionImpl.java
(original)
+++ commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/cpdsadapter/ConnectionImpl.java
Wed Feb 18 15:03:47 2009
@@ -474,11 +474,18 @@
 /* JDBC_4_ANT_KEY_BEGIN */
 
     public boolean isWrapperFor(Class<?> iface) throws SQLException {
-        return connection.isWrapperFor(iface);
+        return iface.isAssignableFrom(getClass()) ||
+                connection.isWrapperFor(iface);
     }
 
     public <T> T unwrap(Class<T> iface) throws SQLException {
-        return connection.unwrap(iface);
+        if (iface.isAssignableFrom(getClass())) {
+            return iface.cast(this);
+        } else if (iface.isAssignableFrom(connection.getClass())) {
+            return iface.cast(connection);
+        } else {
+            return connection.unwrap(iface);
+        }
     }
 
     public Array createArrayOf(String typeName, Object[] elements) throws SQLException {



Mime
View raw message