Bug #70893 Connection.close() maybe throw StackOverflowError
Submitted: 13 Nov 2013 5:40 Modified: 18 Nov 2013 13:28
Reporter: yu xie Email Updates:
Status: Duplicate Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:5.x OS:Any
Assigned to: Alexander Soklakov CPU Architecture:Any
Tags: StackOverflowError Connneciton.close() enableStreamingResults

[13 Nov 2013 5:40] yu xie
Description:
when call Connection.close() method maybe throw StackOverflowError
There program maybe dead recursive

How to repeat:
Step:
1、((StatementImpl)statement).enableStreamingResults()
2、kill session on MySserver or Disconnect the network。
3、Connection.close()

then throw StackOverflow.

stack info(use version 5.1.6):
Exception in thread "main" java.lang.StackOverflowError
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
	at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
	at com.mysql.jdbc.ConnectionImpl.realClose(ConnectionImpl.java:4273)
	at com.mysql.jdbc.ConnectionImpl.cleanup(ConnectionImpl.java:1248)
	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2569)
	at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1564)
	at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1485)
	at com.mysql.jdbc.RowDataDynamic.close(RowDataDynamic.java:195)
	at com.mysql.jdbc.ResultSetImpl.realClose(ResultSetImpl.java:7473)
	at com.mysql.jdbc.ResultSetImpl.close(ResultSetImpl.java:881)
        .....

stack info(use version >=5.1.25):
        at com.mysql.jdbc.ConnectionImpl.realClose(ConnectionImpl.java:4690)
        at com.mysql.jdbc.ConnectionImpl.cleanup(ConnectionImpl.java:1464)
        at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2843)
        at com.mysql.jdbc.StatementImpl.executeSimpleNonQuery(StatementImpl.java:1703)
        at com.mysql.jdbc.RowDataDynamic.close(RowDataDynamic.java:202)
        at com.mysql.jdbc.ResultSetImpl.realClose(ResultSetImpl.java:7474)
        at com.mysql.jdbc.ResultSetImpl.close(ResultSetImpl.java:923)
        at com.mysql.jdbc.StatementImpl.realClose(StatementImpl.java:2585)
        at com.mysql.jdbc.ConnectionImpl.closeAllOpenStatements(ConnectionImpl.java:1658)
        at com.mysql.jdbc.ConnectionImpl.realClose(ConnectionImpl.java:4690)
        at com.mysql.jdbc.ConnectionImpl.cleanup(ConnectionImpl.java:1464)
        at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2843)
        at com.mysql.jdbc.StatementImpl.executeSimpleNonQuery(StatementImpl.java:1703)
        at com.mysql.jdbc.RowDataDynamic.close(RowDataDynamic.java:202)
        at com.mysql.jdbc.ResultSetImpl.realClose(ResultSetImpl.java:7474)
        at com.mysql.jdbc.ResultSetImpl.close(ResultSetImpl.java:923)
        at com.mysql.jdbc.StatementImpl.realClose(StatementImpl.java:2585)
        at com.mysql.jdbc.ConnectionImpl.closeAllOpenStatements(ConnectionImpl.java:1658)
        at com.mysql.jdbc.ConnectionImpl.realClose(ConnectionImpl.java:4690)
[18 Nov 2013 13:28] Alexander Soklakov
Hi Yu,

Thank you for the report.
This is a duplicate of Bug#57432 but it gives a simplified view of the problem.
[18 Nov 2013 13:30] Alexander Soklakov
JUnit test case

Attachment: TestBug70893.java (text/x-java), 2.25 KiB.