提交 c5c89f63 authored 作者: Thomas Mueller's avatar Thomas Mueller

Closing a Statement or PreparedStatement at the same time as executing a…

Closing a Statement or PreparedStatement at the same time as executing a statement could throw a strange exception.
上级 90c23518
...@@ -297,11 +297,15 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -297,11 +297,15 @@ public class JdbcConnection extends TraceObject implements Connection {
if (session == null) { if (session == null) {
return; return;
} }
synchronized (session) { session.cancel();
if (executingStatement != null) { if (executingStatement != null) {
try {
executingStatement.cancel(); executingStatement.cancel();
} catch (NullPointerException e) {
// ignore
} }
session.cancel(); }
synchronized (session) {
try { try {
if (!session.isClosed()) { if (!session.isClosed()) {
try { try {
......
...@@ -82,10 +82,13 @@ public class TestConcurrent extends TestBase { ...@@ -82,10 +82,13 @@ public class TestConcurrent extends TestBase {
conn.close(); conn.close();
t.join(); t.join();
SQLException e = ex[0]; SQLException e = ex[0];
if (e != null && ErrorCode.OBJECT_CLOSED != e.getErrorCode()) { if (e != null) {
if (ErrorCode.OBJECT_CLOSED != e.getErrorCode() &&
ErrorCode.STATEMENT_WAS_CANCELED != e.getErrorCode()) {
throw e; throw e;
} }
} }
} }
}
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论