commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1571776 - in /commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2: ./ cpdsadapter/ datasources/ managed/
Date Tue, 25 Feb 2014 18:02:35 GMT
Author: ggregory
Date: Tue Feb 25 18:02:35 2014
New Revision: 1571776

URL: http://svn.apache.org/r1571776
Log:
Simplify: Statement unnecessarily nested within else clause.

Modified:
    commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java
    commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/DataSourceConnectionFactory.java
    commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/DelegatingConnection.java
    commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/DelegatingResultSet.java
    commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/DriverManagerConnectionFactory.java
    commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/PoolingConnection.java
    commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/PoolingDataSource.java
    commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/PoolingDriver.java
    commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/Utils.java
    commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/cpdsadapter/ConnectionImpl.java
    commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/cpdsadapter/PooledConnectionImpl.java
    commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/InstanceKeyDataSource.java
    commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/ManagedConnection.java

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java?rev=1571776&r1=1571775&r2=1571776&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java
(original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java
Tue Feb 25 18:02:35 2014
@@ -992,9 +992,8 @@ public class BasicDataSource
     public synchronized int getNumActive() {
         if (connectionPool != null) {
             return connectionPool.getNumActive();
-        } else {
-            return 0;
         }
+        return 0;
     }
 
 
@@ -1008,9 +1007,8 @@ public class BasicDataSource
     public synchronized int getNumIdle() {
         if (connectionPool != null) {
             return connectionPool.getNumIdle();
-        } else {
-            return 0;
         }
+        return 0;
     }
 
     /**
@@ -1430,13 +1428,11 @@ public class BasicDataSource
                 Throwable cause = e.getCause();
                 if (cause instanceof SQLException) {
                     throw (SQLException) cause;
-                } else {
-                    throw new SQLException(e);
                 }
+                throw new SQLException(e);
             }
-        } else {
-            return createDataSource().getConnection();
         }
+        return createDataSource().getConnection();
     }
 
 

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/DataSourceConnectionFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/DataSourceConnectionFactory.java?rev=1571776&r1=1571775&r2=1571776&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/DataSourceConnectionFactory.java
(original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/DataSourceConnectionFactory.java
Tue Feb 25 18:02:35 2014
@@ -41,9 +41,8 @@ public class DataSourceConnectionFactory
     public Connection createConnection() throws SQLException {
         if(null == _uname && null == _passwd) {
             return _source.getConnection();
-        } else {
-            return _source.getConnection(_uname,_passwd);
         }
+        return _source.getConnection(_uname,_passwd);
     }
 
     private final String _uname;

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/DelegatingConnection.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/DelegatingConnection.java?rev=1571776&r1=1571775&r2=1571776&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/DelegatingConnection.java
(original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/DelegatingConnection.java
Tue Feb 25 18:02:35 2014
@@ -156,9 +156,8 @@ public class DelegatingConnection<C exte
         Connection innerCon = getInnermostDelegateInternal();
         if (innerCon == null) {
             return c == null;
-        } else {
-            return innerCon.equals(c);
         }
+        return innerCon.equals(c);
     }
 
 
@@ -605,10 +604,9 @@ public class DelegatingConnection<C exte
                 }
                 throw new SQLException
                     ("Connection " + label + " is closed.");
-            } else {
-                throw new SQLException
-                    ("Connection is null.");
             }
+            throw new SQLException
+                ("Connection is null.");
         }
     }
 

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/DelegatingResultSet.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/DelegatingResultSet.java?rev=1571776&r1=1571775&r2=1571776&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/DelegatingResultSet.java
(original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/DelegatingResultSet.java
Tue Feb 25 18:02:35 2014
@@ -104,17 +104,15 @@ public class DelegatingResultSet extends
     public static ResultSet wrapResultSet(Statement stmt, ResultSet rset) {
         if(null == rset) {
             return null;
-        } else {
-            return new DelegatingResultSet(stmt,rset);
         }
+        return new DelegatingResultSet(stmt,rset);
     }
 
     public static ResultSet wrapResultSet(Connection conn, ResultSet rset) {
         if(null == rset) {
             return null;
-        } else {
-            return new DelegatingResultSet(conn,rset);
         }
+        return new DelegatingResultSet(conn,rset);
     }
 
     public ResultSet getDelegate() {

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/DriverManagerConnectionFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/DriverManagerConnectionFactory.java?rev=1571776&r1=1571775&r2=1571776&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/DriverManagerConnectionFactory.java
(original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/DriverManagerConnectionFactory.java
Tue Feb 25 18:02:35 2014
@@ -72,12 +72,10 @@ public class DriverManagerConnectionFact
         if(null == _props) {
             if(_uname == null && _passwd == null) {
                 return DriverManager.getConnection(_connectUri);
-            } else {
-                return DriverManager.getConnection(_connectUri,_uname,_passwd);
             }
-        } else {
-            return DriverManager.getConnection(_connectUri,_props);
+            return DriverManager.getConnection(_connectUri,_uname,_passwd);
         }
+        return DriverManager.getConnection(_connectUri,_props);
     }
 
     private String _connectUri = null;

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/PoolingConnection.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/PoolingConnection.java?rev=1571776&r1=1571775&r2=1571776&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/PoolingConnection.java
(original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/PoolingConnection.java
Tue Feb 25 18:02:35 2014
@@ -317,34 +317,31 @@ public class PoolingConnection extends D
             throws Exception {
         if(null == key) {
             throw new IllegalArgumentException("Prepared statement key is null or invalid.");
-        } else {
-            if (null == key.getResultSetType() && null == key.getResultSetConcurrency()
&& null == key.getAutoGeneratedKeys()) {
-                if (key.getStmtType() == StatementType.PREPARED_STATEMENT ) {
-                    @SuppressWarnings({"rawtypes", "unchecked"}) // Unable to find way to
avoid this
-                    PoolablePreparedStatement pps = new PoolablePreparedStatement(
-                            getDelegate().prepareStatement(key.getSql()), key, _pstmtPool,
this);
-                    return new DefaultPooledObject<DelegatingPreparedStatement>(pps);
-                } else {
-                    return new DefaultPooledObject<DelegatingPreparedStatement>(
-                            new PoolableCallableStatement(getDelegate().prepareCall( key.getSql()),
key, _pstmtPool, this));
-                }
-            } else if (null == key.getResultSetType() && null == key.getResultSetConcurrency()){
+        }
+        if (null == key.getResultSetType() && null == key.getResultSetConcurrency()
&& null == key.getAutoGeneratedKeys()) {
+            if (key.getStmtType() == StatementType.PREPARED_STATEMENT ) {
                 @SuppressWarnings({"rawtypes", "unchecked"}) // Unable to find way to avoid
this
                 PoolablePreparedStatement pps = new PoolablePreparedStatement(
-                        getDelegate().prepareStatement(key.getSql(), key.getAutoGeneratedKeys().intValue()),
key, _pstmtPool, this);
+                        getDelegate().prepareStatement(key.getSql()), key, _pstmtPool, this);
+                return new DefaultPooledObject<DelegatingPreparedStatement>(pps);
+            }
+            return new DefaultPooledObject<DelegatingPreparedStatement>(
+                    new PoolableCallableStatement(getDelegate().prepareCall( key.getSql()),
key, _pstmtPool, this));
+        } else if (null == key.getResultSetType() && null == key.getResultSetConcurrency()){
+            @SuppressWarnings({"rawtypes", "unchecked"}) // Unable to find way to avoid this
+            PoolablePreparedStatement pps = new PoolablePreparedStatement(
+                    getDelegate().prepareStatement(key.getSql(), key.getAutoGeneratedKeys().intValue()),
key, _pstmtPool, this);
+            return new DefaultPooledObject<DelegatingPreparedStatement>(pps);
+        } else { // Both _resultSetType and _resultSetConcurrency are non-null here (both
or neither are set by constructors)
+            if(key.getStmtType() == StatementType.PREPARED_STATEMENT) {
+                @SuppressWarnings({"rawtypes", "unchecked"}) // Unable to find way to avoid
this
+                PoolablePreparedStatement pps = new PoolablePreparedStatement(getDelegate().prepareStatement(
+                        key.getSql(), key.getResultSetType().intValue(),key.getResultSetConcurrency().intValue()),
key, _pstmtPool, this);
                 return new DefaultPooledObject<DelegatingPreparedStatement>(pps);
-            } else { // Both _resultSetType and _resultSetConcurrency are non-null here (both
or neither are set by constructors)
-                if(key.getStmtType() == StatementType.PREPARED_STATEMENT) {
-                    @SuppressWarnings({"rawtypes", "unchecked"}) // Unable to find way to
avoid this
-                    PoolablePreparedStatement pps = new PoolablePreparedStatement(getDelegate().prepareStatement(
-                            key.getSql(), key.getResultSetType().intValue(),key.getResultSetConcurrency().intValue()),
key, _pstmtPool, this);
-                    return new DefaultPooledObject<DelegatingPreparedStatement>(pps);
-                } else {
-                    return new DefaultPooledObject<DelegatingPreparedStatement>(
-                            new PoolableCallableStatement( getDelegate().prepareCall(
-                                    key.getSql(),key.getResultSetType().intValue(), key.getResultSetConcurrency().intValue()),
key, _pstmtPool, this));
-                }
             }
+            return new DefaultPooledObject<DelegatingPreparedStatement>(
+                    new PoolableCallableStatement( getDelegate().prepareCall(
+                            key.getSql(),key.getResultSetType().intValue(), key.getResultSetConcurrency().intValue()),
key, _pstmtPool, this));
         }
     }
 
@@ -410,9 +407,8 @@ public class PoolingConnection extends D
     public String toString() {
         if (_pstmtPool != null ) {
             return "PoolingConnection: " + _pstmtPool.toString();
-        } else {
-            return "PoolingConnection: null";
         }
+        return "PoolingConnection: null";
     }
 
     protected static enum StatementType {

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/PoolingDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/PoolingDataSource.java?rev=1571776&r1=1571775&r2=1571776&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/PoolingDataSource.java
(original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/PoolingDataSource.java
Tue Feb 25 18:02:35 2014
@@ -187,9 +187,8 @@ public class PoolingDataSource<C extends
         public D getDelegate() {
             if (isAccessToUnderlyingConnectionAllowed()) {
                 return super.getDelegate();
-            } else {
-                return null;
             }
+            return null;
         }
 
         /**
@@ -199,9 +198,8 @@ public class PoolingDataSource<C extends
         public Connection getInnermostDelegate() {
             if (isAccessToUnderlyingConnectionAllowed()) {
                 return super.getInnermostDelegate();
-            } else {
-                return null;
             }
+            return null;
         }
 
         @Override

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/PoolingDriver.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/PoolingDriver.java?rev=1571776&r1=1571775&r2=1571776&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/PoolingDriver.java (original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/PoolingDriver.java Tue
Feb 25 18:02:35 2014
@@ -139,9 +139,8 @@ public class PoolingDriver implements Dr
             } catch(Exception e) {
                 throw new SQLException("Cannot get a connection, general error: " + e.getMessage(),
e);
             }
-        } else {
-            return null;
         }
+        return null;
     }
 
     @Override
@@ -223,9 +222,8 @@ public class PoolingDriver implements Dr
         public Connection getDelegate() {
             if (isAccessToUnderlyingConnectionAllowed()) {
                 return super.getDelegate();
-            } else {
-                return null;
             }
+            return null;
         }
 
         /**
@@ -235,9 +233,8 @@ public class PoolingDriver implements Dr
         public Connection getInnermostDelegate() {
             if (isAccessToUnderlyingConnectionAllowed()) {
                 return super.getInnermostDelegate();
-            } else {
-                return null;
             }
+            return null;
         }
     }
 }

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/Utils.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/Utils.java?rev=1571776&r1=1571775&r2=1571776&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/Utils.java (original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/Utils.java Tue Feb 25
18:02:35 2014
@@ -102,9 +102,8 @@ public class Utils {
         String msg =  messages.getString(key);
         if (args == null || args.length == 0) {
             return msg;
-        } else {
-            MessageFormat mf = new MessageFormat(msg);
-            return mf.format(args, new StringBuffer(), null).toString();
         }
+        MessageFormat mf = new MessageFormat(msg);
+        return mf.format(args, new StringBuffer(), null).toString();
     }
 }

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/cpdsadapter/ConnectionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/cpdsadapter/ConnectionImpl.java?rev=1571776&r1=1571775&r2=1571776&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/cpdsadapter/ConnectionImpl.java
(original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/cpdsadapter/ConnectionImpl.java
Tue Feb 25 18:02:35 2014
@@ -211,9 +211,8 @@ class ConnectionImpl extends DelegatingC
     public Connection getDelegate() {
         if (isAccessToUnderlyingConnectionAllowed()) {
             return getDelegateInternal();
-        } else {
-            return null;
         }
+        return null;
     }
 
     /**
@@ -225,9 +224,8 @@ class ConnectionImpl extends DelegatingC
     public Connection getInnermostDelegate() {
         if (isAccessToUnderlyingConnectionAllowed()) {
             return super.getInnermostDelegateInternal();
-        } else {
-            return null;
         }
+        return null;
     }
 
 }

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/cpdsadapter/PooledConnectionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/cpdsadapter/PooledConnectionImpl.java?rev=1571776&r1=1571775&r2=1571776&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/cpdsadapter/PooledConnectionImpl.java
(original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/cpdsadapter/PooledConnectionImpl.java
Tue Feb 25 18:02:35 2014
@@ -248,14 +248,13 @@ class PooledConnectionImpl implements Po
     PreparedStatement prepareStatement(String sql) throws SQLException {
         if (pstmtPool == null) {
             return connection.prepareStatement(sql);
-        } else {
-            try {
-                return pstmtPool.borrowObject(createKey(sql));
-            } catch (RuntimeException e) {
-                throw e;
-            } catch (Exception e) {
-                throw new SQLException("Borrow prepareStatement from pool failed", e);
-            }
+        }
+        try {
+            return pstmtPool.borrowObject(createKey(sql));
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new SQLException("Borrow prepareStatement from pool failed", e);
         }
     }
 
@@ -280,15 +279,14 @@ class PooledConnectionImpl implements Po
             throws SQLException {
         if (pstmtPool == null) {
             return connection.prepareStatement(sql, resultSetType, resultSetConcurrency);
-        } else {
-            try {
-                return pstmtPool.borrowObject(
-                        createKey(sql,resultSetType,resultSetConcurrency));
-            } catch (RuntimeException e) {
-                throw e;
-            } catch (Exception e) {
-                throw new SQLException("Borrow prepareStatement from pool failed", e);
-            }
+        }
+        try {
+            return pstmtPool.borrowObject(
+                    createKey(sql,resultSetType,resultSetConcurrency));
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new SQLException("Borrow prepareStatement from pool failed", e);
         }
     }
 
@@ -307,14 +305,13 @@ class PooledConnectionImpl implements Po
             throws SQLException {
         if (pstmtPool == null) {
             return connection.prepareStatement(sql, autoGeneratedKeys);
-        } else {
-            try {
-                return pstmtPool.borrowObject(createKey(sql,autoGeneratedKeys));
-            } catch (RuntimeException e) {
-                throw e;
-            } catch (Exception e) {
-                throw new SQLException("Borrow prepareStatement from pool failed", e);
-            }
+        }
+        try {
+            return pstmtPool.borrowObject(createKey(sql,autoGeneratedKeys));
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new SQLException("Borrow prepareStatement from pool failed", e);
         }
     }
 
@@ -324,15 +321,14 @@ class PooledConnectionImpl implements Po
         if (pstmtPool == null) {
             return connection.prepareStatement(sql, resultSetType,
                     resultSetConcurrency, resultSetHoldability);
-        } else {
-            try {
-                return pstmtPool.borrowObject(createKey(sql, resultSetType,
-                        resultSetConcurrency, resultSetHoldability));
-            } catch (RuntimeException e) {
-                throw e;
-            } catch (Exception e) {
-                throw new SQLException("Borrow prepareStatement from pool failed", e);
-            }
+        }
+        try {
+            return pstmtPool.borrowObject(createKey(sql, resultSetType,
+                    resultSetConcurrency, resultSetHoldability));
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new SQLException("Borrow prepareStatement from pool failed", e);
         }
     }
 
@@ -340,14 +336,13 @@ class PooledConnectionImpl implements Po
     throws SQLException {
         if (pstmtPool == null) {
             return connection.prepareStatement(sql, columnIndexes);
-        } else {
-            try {
-                return pstmtPool.borrowObject(createKey(sql, columnIndexes));
-            } catch (RuntimeException e) {
-                throw e;
-            } catch (Exception e) {
-                throw new SQLException("Borrow prepareStatement from pool failed", e);
-            }
+        }
+        try {
+            return pstmtPool.borrowObject(createKey(sql, columnIndexes));
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new SQLException("Borrow prepareStatement from pool failed", e);
         }
     }
 
@@ -355,14 +350,13 @@ class PooledConnectionImpl implements Po
     throws SQLException {
         if (pstmtPool == null) {
             return connection.prepareStatement(sql, columnNames);
-        } else {
-            try {
-                return pstmtPool.borrowObject(createKey(sql, columnNames));
-            } catch (RuntimeException e) {
-                throw e;
-            } catch (Exception e) {
-                throw new SQLException("Borrow prepareStatement from pool failed", e);
-            }
+        }
+        try {
+            return pstmtPool.borrowObject(createKey(sql, columnNames));
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new SQLException("Borrow prepareStatement from pool failed", e);
         }
     }
 
@@ -429,31 +423,28 @@ class PooledConnectionImpl implements Po
     public PooledObject<PoolablePreparedStatement<PStmtKeyCPDS,PoolablePreparedStatementStub>>
makeObject(PStmtKeyCPDS key) throws Exception {
         if (null == key) {
             throw new IllegalArgumentException();
-        } else {
-            // _openPstmts++;
-            if (null == key.getResultSetType()
-                    && null == key.getResultSetConcurrency()) {
-                if (null == key.getAutoGeneratedKeys()) {
-                    return new DefaultPooledObject<PoolablePreparedStatement<PStmtKeyCPDS,PoolablePreparedStatementStub>>(
-                            new PoolablePreparedStatementStub(
-                                    connection.prepareStatement(key.getSql()),
-                                    key, pstmtPool, delegatingConnection));
-                } else {
-                    return new DefaultPooledObject<PoolablePreparedStatement<PStmtKeyCPDS,PoolablePreparedStatementStub>>(
-                            new PoolablePreparedStatementStub(
-                                    connection.prepareStatement(key.getSql(),
-                                            key.getAutoGeneratedKeys().intValue()),
-                                    key, pstmtPool, delegatingConnection));
-                }
-            } else {
+        }
+        // _openPstmts++;
+        if (null == key.getResultSetType()
+                && null == key.getResultSetConcurrency()) {
+            if (null == key.getAutoGeneratedKeys()) {
                 return new DefaultPooledObject<PoolablePreparedStatement<PStmtKeyCPDS,PoolablePreparedStatementStub>>(
                         new PoolablePreparedStatementStub(
-                                connection.prepareStatement(key.getSql(),
-                                        key.getResultSetType().intValue(),
-                                        key.getResultSetConcurrency().intValue()),
-                                        key, pstmtPool, delegatingConnection));
+                                connection.prepareStatement(key.getSql()),
+                                key, pstmtPool, delegatingConnection));
             }
+            return new DefaultPooledObject<PoolablePreparedStatement<PStmtKeyCPDS,PoolablePreparedStatementStub>>(
+                    new PoolablePreparedStatementStub(
+                            connection.prepareStatement(key.getSql(),
+                                    key.getAutoGeneratedKeys().intValue()),
+                            key, pstmtPool, delegatingConnection));
         }
+        return new DefaultPooledObject<PoolablePreparedStatement<PStmtKeyCPDS,PoolablePreparedStatementStub>>(
+                new PoolablePreparedStatementStub(
+                        connection.prepareStatement(key.getSql(),
+                                key.getResultSetType().intValue(),
+                                key.getResultSetConcurrency().intValue()),
+                                key, pstmtPool, delegatingConnection));
     }
 
     /**

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/InstanceKeyDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/InstanceKeyDataSource.java?rev=1571776&r1=1571775&r2=1571776&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/InstanceKeyDataSource.java
(original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/InstanceKeyDataSource.java
Tue Feb 25 18:02:35 2014
@@ -969,12 +969,11 @@ public abstract class InstanceKeyDataSou
                 }
                 if (info != null && password != null && password.equals(info.getPassword()))
{
                     break;
-                } else {
-                    if (info != null) {
-                        manager.invalidate(info.getPooledConnection());
-                    }
-                    info = null;
                 }
+                if (info != null) {
+                    manager.invalidate(info.getPooledConnection());
+                }
+                info = null;
             }
             if (info == null) {
                 throw new SQLException("Cannot borrow connection from pool - password change
failure.");

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/ManagedConnection.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/ManagedConnection.java?rev=1571776&r1=1571775&r2=1571776&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/ManagedConnection.java
(original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/ManagedConnection.java
Tue Feb 25 18:02:35 2014
@@ -71,12 +71,11 @@ public class ManagedConnection<C extends
                     throw new SQLException("Connection can not be used while enlisted in
another transaction");
                 }
                 return;
-            } else {
-                // transaction should have been cleared up by TransactionContextListener,
but in
-                // rare cases another lister could have registered which uses the connection
before
-                // our listener is called.  In that rare case, trigger the transaction complete
call now
-                transactionComplete();
             }
+            // transaction should have been cleared up by TransactionContextListener, but
in
+            // rare cases another lister could have registered which uses the connection
before
+            // our listener is called.  In that rare case, trigger the transaction complete
call now
+            transactionComplete();
         }
 
         // the existing transaction context ended (or we didn't have one), get the active
transaction context
@@ -258,17 +257,15 @@ public class ManagedConnection<C extends
     public C getDelegate() {
         if (isAccessToUnderlyingConnectionAllowed()) {
             return getDelegateInternal();
-        } else {
-            return null;
         }
+        return null;
     }
 
     @Override
     public Connection getInnermostDelegate() {
         if (isAccessToUnderlyingConnectionAllowed()) {
             return super.getInnermostDelegateInternal();
-        } else {
-            return null;
         }
+        return null;
     }
 }



Mime
View raw message