https://bz.apache.org/bugzilla/show_bug.cgi?id=65347
Bug ID: 65347
Summary: The equals method from statements generated by the
StatementFacade throws both Illegal Argument Exception
and NullPointerExceptions
Product: Tomcat Modules
Version: unspecified
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P2
Component: jdbc-pool
Assignee: [email protected]
Reporter: [email protected]
Target Milestone: ---
Created attachment 37885
--> https://bz.apache.org/bugzilla/attachment.cgi?id=37885&action=edit
Unit test cases for the Statement Facade class
tomcat-jdbc versions: 10.0.6 and 9.0.26
Statement objects created by the StatementFacade will throw exceptions from the
equals method, if the provided comparison object is not a
"java.lang.refelect.Proxy". According to the javadoc for object this method
should never throw and exception, but rather it should return false in those
cases.
This becomes an issue when prepared statements are stored and retrieved from
HashMaps and HashSets.
A proposed fix is to update the embedded StatementProxy.invoke() method with
the following:
if (compare(EQUALS_VAL, method)) {
try {
Object rhs = args[0];
if (rhs instanceof Proxy) {
rhs = Proxy.getInvocationHandler(rhs);
}
return Boolean.valueOf(this.equals(rhs));
} catch (Exception e) {
return Boolean.FALSE;
}
}
Also attached is a unit test.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]