=== modified file 'CHANGES' --- CHANGES 2009-10-19 20:04:20 +0000 +++ CHANGES 2009-10-30 18:34:58 +0000 @@ -3,6 +3,9 @@ mm-dd-yy - Version 5.1.11 (not yet released) + - Fix for BUG#48442 - Load-balanced Connection object returns inconsistent results for hashCode() and equals() + dependent upon state of underlying connections. + - Fix for BUG#48172 - Batch rewrite requires space immediately after "VALUES" 09-22-09 - Version 5.1.10 === modified file 'src/com/mysql/jdbc/LoadBalancingConnectionProxy.java' --- src/com/mysql/jdbc/LoadBalancingConnectionProxy.java 2009-03-06 21:56:57 +0000 +++ src/com/mysql/jdbc/LoadBalancingConnectionProxy.java 2009-10-30 18:33:52 +0000 @@ -310,11 +310,11 @@ String methodName = method.getName(); if ("equals".equals(methodName) && args.length == 1) { - if (args[0] instanceof Proxy) { - return Boolean.valueOf((((Proxy)args[0]).equals(this))); - } - - return Boolean.valueOf(equals(args[0])); + return Boolean.valueOf(this.equals(args[0])); + } + + if ("hashCode".equals(methodName)) { + return Integer.valueOf(this.hashCode()); } if ("close".equals(methodName)) { === modified file 'src/testsuite/regression/ConnectionRegressionTest.java' --- src/testsuite/regression/ConnectionRegressionTest.java 2009-09-22 20:47:27 +0000 +++ src/testsuite/regression/ConnectionRegressionTest.java 2009-10-30 18:38:20 +0000 @@ -2398,6 +2398,37 @@ } } + + public void testBug48442() throws Exception { + + Properties props = new Properties(); + props.setProperty("loadBalanceStrategy", "random"); + Connection conn2 = this.getUnreliableLoadBalancedConnection(newString[]{"first", "second"}, props); + + assertNotNull("Connection should not be null", conn2); + conn2.setAutoCommit(false); + UnreliableSocketFactory.downHost("second"); + int hc = 0; + try { + try{ + conn2.createStatement().execute("SELECT 1"); + } catch (SQLException e){ + conn2.createStatement().execute("SELECT 1"); + } + hc = conn2.hashCode(); + conn2.commit(); + UnreliableSocketFactory.dontDownHost("second"); + UnreliableSocketFactory.downHost("first"); + try{ + conn2.commit(); + } catch (SQLException e){} + assertTrue(hc == conn2.hashCode()); + + + } finally { + closeMemberJDBCResources(); + } + } public void testBug45171() throws Exception { List statementsToTest = new LinkedList();