commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1557682 - /commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/PStmtKey.java
Date Mon, 13 Jan 2014 11:43:17 GMT
Author: markt
Date: Mon Jan 13 11:43:16 2014
New Revision: 1557682

URL: http://svn.apache.org/r1557682
Log:
Fix possible NPEs in r1557679
(using Eclipse's generated code for equals() and hashCode() with just formatting changes)

Modified:
    commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/PStmtKey.java

Modified: commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/PStmtKey.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/PStmtKey.java?rev=1557682&r1=1557681&r2=1557682&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/PStmtKey.java (original)
+++ commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/PStmtKey.java Mon Jan 13 11:43:16
2014
@@ -96,19 +96,48 @@ public class PStmtKey {
 
     @Override
     public boolean equals(Object obj) {
-        if (this == obj)
+        if (this == obj) {
             return true;
-        if (obj == null)
+        }
+        if (obj == null) {
             return false;
-        if (getClass() != obj.getClass())
+        }
+        if (getClass() != obj.getClass()) {
             return false;
-        PStmtKey key = (PStmtKey) obj;
-        return( ((null == _sql && null == key._sql) || _sql.equals(key._sql)) &&
-                ((null == _catalog && null == key._catalog) || _catalog.equals(key._catalog))
&&
-                ((null == _resultSetType && null == key._resultSetType) || _resultSetType.equals(key._resultSetType))
&&
-                ((null == _resultSetConcurrency && null == key._resultSetConcurrency)
|| _resultSetConcurrency.equals(key._resultSetConcurrency)) &&
-                (_stmtType == key._stmtType)
-              );
+        }
+        PStmtKey other = (PStmtKey) obj;
+        if (_catalog == null) {
+            if (other._catalog != null) {
+                return false;
+            }
+        } else if (!_catalog.equals(other._catalog)) {
+            return false;
+        }
+        if (_resultSetConcurrency == null) {
+            if (other._resultSetConcurrency != null) {
+                return false;
+            }
+        } else if (!_resultSetConcurrency.equals(other._resultSetConcurrency)) {
+            return false;
+        }
+        if (_resultSetType == null) {
+            if (other._resultSetType != null) {
+                return false;
+            }
+        } else if (!_resultSetType.equals(other._resultSetType)) {
+            return false;
+        }
+        if (_sql == null) {
+            if (other._sql != null) {
+                return false;
+            }
+        } else if (!_sql.equals(other._sql)) {
+            return false;
+        }
+        if (_stmtType != other._stmtType) {
+            return false;
+        }
+        return true;
     }
 
     @Override



Mime
View raw message