Bug #48442 Load-balanced Connection object inconsistent results for hashCode() and equals()

Submitted: 30 Oct 2009 18:17 Modified: 3 Nov 2009 15:43
Reporter: Todd Farmer (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:5.1.10 OS:Any
Assigned to: Todd Farmer CPU Architecture:Any

[30 Oct 2009 18:17] Todd Farmer
Description:
The current implementation for load-balanced Connection uses a proxy, which delegates method calls to underlying Connection objects - including equals() and hashCode().  This means that successive calls to hashCode() on the same object may return different values, if the proxy state has changed such that it is now utilizing a different underlying connection.

While JDBC specs are silent regarding equals and hashcode contracts in this area, it would be more appropriate to not delegate these calls, and instead return the results of method calls executed on the proxy object directly.

How to repeat:
Test case to be attached.

Suggested fix:
Don't delegate calls to equals() or hashCode() to the proxied connection.
[30 Oct 2009 18:47] Todd Farmer
Pushed in r870, will be in next nightly snapshot build and 5.1.11.
[30 Oct 2009 18:51] Todd Farmer
Patch with test case.

Attachment: bug48442.patch (text/x-patch), 3.03 KiB.

[3 Nov 2009 15:43] Tony Bedford
An entry has been added to the 5.1.11 changelog:

The implementation for load-balanced Connection used a proxy, which delegated method calls, including equals() and hashCode(), to underlying Connection objects. This meant that successive calls to hashCode() on the same object potentially returned different values, if the proxy state had changed such that it was utilizing a different underlying connection.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.039 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.