/* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. The MySQL Connector/J is licensed under the terms of the GPLv2 , like most MySQL Connectors. There are special exceptions to the terms and conditions of the GPLv2 as it is applied to this software, see the FLOSS License Exception . This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package testsuite.simple; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.Properties; import testsuite.BaseTestCase; import com.mysql.jdbc.StatementImpl; public class TestBug70893 extends BaseTestCase { public TestBug70893(String name) { super(name); } /** * @param args */ public static void main(String[] args) { junit.textui.TestRunner.run(TestBug70893.class); } /** * Tests fix for BUG#70893 - Connection.close() maybe throw StackOverflowError * * @throws SQLException */ public void testBug70893() throws SQLException { Properties properties = new Properties(); Connection connection = getConnectionWithProps(properties); String connectionId = getSingleIndexedValueWithQuery(connection, 1, "SELECT CONNECTION_ID()").toString(); try { Statement st = connection.createStatement(); ((StatementImpl)st).enableStreamingResults(); ResultSet res = st.executeQuery("select 1"); this.stmt.executeUpdate("KILL " + connectionId); Thread.sleep(1000); st.close(); } catch (InterruptedException e) { e.printStackTrace(); } finally { connection.close(); } } }