Bug #69557 Inconsistencies in Statement proxies created by LoadBalancingConnectionProxy
Submitted: 24 Jun 2013 12:15 Modified: 18 Nov 2013 15:05
Reporter: Donnchadh Ó Donnabháin Email Updates:
Status: Verified Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:5.1.25 OS:Linux (CentOS 6.3)
Assigned to: Assigned Account CPU Architecture:Any

[24 Jun 2013 12:15] Donnchadh Ó Donnabháin
Description:
Since JDBC4ResultSet doesn't directly implement a JDBC interface,
LoadBalancingConnectionProxy.isInterfaceJdbc(JDBC4ResultSet.class) returns false.
This means that it isn't proxied and the value return by getStatement() return the wrapped statement rather than the proxy.

I also don't see any logic here to ensure that the same object doesn't have multiple proxies, such that
 statement.executeQuery(query).getStatement() == statement, for example.

This results in issues such as https://hibernate.atlassian.net/browse/HHH-8210.

How to repeat:
* Enable loadbancing a connection url such as jdbc:mysql:replication://mysqlhost,mysqlreadonlyhost/mydatabase?roundRobinLoadBalance=true and using com.mysql.jdbc.ReplicationDriver
*
  PreparedStatement ps = connection.prepareStatement(myQuery);
  assertTrue(statement.executeQuery(query).getStatement() == statement);

Suggested fix:
Should the statement proxy call ResultSetInternalMethods.setStatementWrapper() ?
[26 Jun 2013 9:42] Alexander Soklakov
Hi Donnchadh,

Thanks for this report. We need to analyze the issue. Could you additionally describe your environment?
[27 Jun 2013 11:27] Donnchadh Ó Donnabháin
The environment is as follows
CentOS 6.3 - x86_64
JDK 1.7.0_21 - x86_64
Connector/J 5.1.25
Tomcat-pool 7.0.41

Also;
Spring Framework 3.2.2
Hibernate 4.2.2
MySQL 5.5.30
Tomcat 7.0.41
[18 Nov 2013 15:05] Alexander Soklakov
Verified by code review.