Skip to content

Commit 6df8eba

Browse files
committed
Flip null test
1 parent 6af9e7d commit 6df8eba

7 files changed

Lines changed: 9 additions & 9 deletions

File tree

src/main/java/org/apache/commons/dbcp2/DataSourceConnectionFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public DataSourceConnectionFactory(final DataSource dataSource, final String use
7979

8080
@Override
8181
public Connection createConnection() throws SQLException {
82-
if (null == userName && null == userPassword) {
82+
if (userName == null && userPassword == null) {
8383
return dataSource.getConnection();
8484
}
8585
return dataSource.getConnection(userName, Utils.toString(userPassword));

src/main/java/org/apache/commons/dbcp2/DelegatingResultSet.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public final class DelegatingResultSet extends AbandonedTrace implements ResultS
6464
* @return a new delegate.
6565
*/
6666
public static ResultSet wrapResultSet(final Connection connection, final ResultSet resultSet) {
67-
if (null == resultSet) {
67+
if (resultSet == null) {
6868
return null;
6969
}
7070
return new DelegatingResultSet(connection, resultSet);
@@ -80,7 +80,7 @@ public static ResultSet wrapResultSet(final Connection connection, final ResultS
8080
* @return a new delegate.
8181
*/
8282
public static ResultSet wrapResultSet(final Statement statement, final ResultSet resultSet) {
83-
if (null == resultSet) {
83+
if (resultSet == null) {
8484
return null;
8585
}
8686
return new DelegatingResultSet(statement, resultSet);

src/main/java/org/apache/commons/dbcp2/DriverManagerConnectionFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public DriverManagerConnectionFactory(final String connectionUri, final String u
113113

114114
@Override
115115
public Connection createConnection() throws SQLException {
116-
if (null == properties) {
116+
if (properties == null) {
117117
if (userName == null && userPassword == null) {
118118
return DriverManager.getConnection(connectionUri);
119119
}

src/main/java/org/apache/commons/dbcp2/PoolingConnection.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ public KeyedObjectPool<PStmtKey, DelegatingPreparedStatement> getStatementPool()
360360
@SuppressWarnings("resource")
361361
@Override
362362
public PooledObject<DelegatingPreparedStatement> makeObject(final PStmtKey key) throws SQLException {
363-
if (null == key) {
363+
if (key == null) {
364364
throw new IllegalArgumentException("Prepared statement key is null or invalid.");
365365
}
366366
if (key.getStmtType() == StatementType.PREPARED_STATEMENT) {
@@ -480,7 +480,7 @@ public CallableStatement prepareCall(final String sql, final int resultSetType,
480480
* Wraps an underlying exception.
481481
*/
482482
private PreparedStatement prepareStatement(final PStmtKey key) throws SQLException {
483-
if (null == stmtPool) {
483+
if (stmtPool == null) {
484484
throw new SQLException("Statement pool is null - closed or invalid PoolingConnection.");
485485
}
486486
try {

src/main/java/org/apache/commons/dbcp2/PoolingDriver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ public Connection connect(final String url, final Properties info) throws SQLExc
185185
*/
186186
public synchronized ObjectPool<? extends Connection> getConnectionPool(final String name) throws SQLException {
187187
final ObjectPool<? extends Connection> pool = pools.get(name);
188-
if (null == pool) {
188+
if (pool == null) {
189189
throw new SQLException("Pool not registered: " + name);
190190
}
191191
return pool;

src/main/java/org/apache/commons/dbcp2/cpdsadapter/PooledConnectionImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ public synchronized boolean isAccessToUnderlyingConnectionAllowed() {
422422
@SuppressWarnings("resource")
423423
@Override
424424
public PooledObject<DelegatingPreparedStatement> makeObject(final PStmtKey key) throws SQLException {
425-
if (null == key) {
425+
if (key == null) {
426426
throw new IllegalArgumentException("Prepared statement key is null or invalid.");
427427
}
428428
if (key.getStmtType() == StatementType.PREPARED_STATEMENT) {

src/main/java/org/apache/commons/dbcp2/datasources/InstanceKeyDataSource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ public Connection getConnection(final String userName, final String userPassword
251251
}
252252

253253
// Password on PooledConnectionAndInfo does not match
254-
if (!(null == userPassword ? null == info.getPassword() : userPassword.equals(info.getPassword()))) {
254+
if (!(userPassword == null ? info.getPassword() == null : userPassword.equals(info.getPassword()))) {
255255
try { // See if password has changed by attempting connection
256256
testCPDS(userName, userPassword);
257257
} catch (final SQLException ex) {

0 commit comments

Comments
 (0)