TransactionAwareDataSourceProxy locally handles get/clearWarnings call
Closes gh-23346
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2017 the original author or authors.
|
* Copyright 2002-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -124,7 +124,7 @@ public class TransactionAwareDataSourceProxy extends DelegatingDataSource {
|
|||||||
/**
|
/**
|
||||||
* Wraps the given Connection with a proxy that delegates every method call to it
|
* Wraps the given Connection with a proxy that delegates every method call to it
|
||||||
* but delegates {@code close()} calls to DataSourceUtils.
|
* but delegates {@code close()} calls to DataSourceUtils.
|
||||||
* @param targetDataSource DataSource that the Connection came from
|
* @param targetDataSource the DataSource that the Connection came from
|
||||||
* @return the wrapped Connection
|
* @return the wrapped Connection
|
||||||
* @see java.sql.Connection#close()
|
* @see java.sql.Connection#close()
|
||||||
* @see DataSourceUtils#doReleaseConnection
|
* @see DataSourceUtils#doReleaseConnection
|
||||||
@@ -203,6 +203,10 @@ public class TransactionAwareDataSourceProxy extends DelegatingDataSource {
|
|||||||
return true;
|
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")) {
|
else if (method.getName().equals("close")) {
|
||||||
// Handle close method: only close if not within a transaction.
|
// Handle close method: only close if not within a transaction.
|
||||||
DataSourceUtils.doReleaseConnection(this.target, this.targetDataSource);
|
DataSourceUtils.doReleaseConnection(this.target, this.targetDataSource);
|
||||||
|
|||||||
Reference in New Issue
Block a user