SakaiPoolableConnectionFactory: Measuring string against reference [Static code review]

Description

Not sure if this will cause any issues in a sensitive part of the code . What does the developer think?

Class: org.apache.commons.dbcp.SakaiPoolableConnectionFactory

Rule: ES_COMPARING_STRINGS_WITH_EQ
See: http://qa1-nl.sakaiproject.org/codereview/bug_dashboard/findbugs_BAD_PRACTICE.html
See: (See java.lang.String#intern() )

May lead to unpredictable result

274 if ((_defaultCatalog != null) && (conn.getCatalog() != _defaultCatalog))
275 {
276 conn.setCatalog(_defaultCatalog);
277 }

Activity

Show:

Lance Speelmon February 14, 2008 at 2:48 PM

svn diff
Index: db-impl/ext/src/java/org/apache/commons/dbcp/SakaiPoolableConnectionFactory.java
===================================================================
— db-impl/ext/src/java/org/apache/commons/dbcp/SakaiPoolableConnectionFactory.java (revision 41205)
+++ db-impl/ext/src/java/org/apache/commons/dbcp/SakaiPoolableConnectionFactory.java (working copy)
@@ -271,7 +271,7 @@
{
conn.setReadOnly(_defaultReadOnly.booleanValue());
}
- if ((_defaultCatalog != null) && (conn.getCatalog() != _defaultCatalog))
+ if ((_defaultCatalog

_defaultCatalog.equals(conn.getCatalog())))
{
conn.setCatalog(_defaultCatalog);
}
/Develop/trunk/db$ svn ci
Sending db-impl/ext/src/java/org/apache/commons/dbcp/SakaiPoolableConnectionFactory.java
Transmitting file data .
Committed revision 41213.

Peter Knoop February 14, 2008 at 1:03 PM

Lance, could you look into this one? Thanks.

Fixed

Details

Priority

Affects versions

Fix versions

Assignee

Reporter

Environment

N/A Static code review
Created February 12, 2008 at 6:05 AM
Updated March 27, 2012 at 7:07 AM
Resolved February 14, 2008 at 2:48 PM