Consistent suppression of get/clearWarnings without target connection
See gh-23346
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -354,18 +354,12 @@ public class LazyConnectionDataSourceProxy extends DelegatingDataSource {
|
||||
this.holdability = (Integer) args[0];
|
||||
return null;
|
||||
}
|
||||
else if (method.getName().equals("commit")) {
|
||||
else if (method.getName().equals("commit") || method.getName().equals("rollback")) {
|
||||
// Ignore: no statements created yet.
|
||||
return null;
|
||||
}
|
||||
else if (method.getName().equals("rollback")) {
|
||||
// Ignore: no statements created yet.
|
||||
return null;
|
||||
}
|
||||
else if (method.getName().equals("getWarnings")) {
|
||||
return null;
|
||||
}
|
||||
else if (method.getName().equals("clearWarnings")) {
|
||||
else if (method.getName().equals("getWarnings") || method.getName().equals("clearWarnings")) {
|
||||
// Ignore: no warnings to expose yet.
|
||||
return null;
|
||||
}
|
||||
else if (method.getName().equals("close")) {
|
||||
|
||||
@@ -203,10 +203,6 @@ public class TransactionAwareDataSourceProxy extends DelegatingDataSource {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (method.getName().equals("getWarnings") || method.getName().equals("clearWarnings")) {
|
||||
// Avoid creation of target Connection on pre-close cleanup (e.g. in Hibernate Session)
|
||||
return null;
|
||||
}
|
||||
else if (method.getName().equals("close")) {
|
||||
// Handle close method: only close if not within a transaction.
|
||||
DataSourceUtils.doReleaseConnection(this.target, this.targetDataSource);
|
||||
@@ -218,6 +214,10 @@ public class TransactionAwareDataSourceProxy extends DelegatingDataSource {
|
||||
}
|
||||
|
||||
if (this.target == null) {
|
||||
if (method.getName().equals("getWarnings") || method.getName().equals("clearWarnings")) {
|
||||
// Avoid creation of target Connection on pre-close cleanup (e.g. Hibernate Session)
|
||||
return null;
|
||||
}
|
||||
if (this.closed) {
|
||||
throw new SQLException("Connection handle already closed");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user