From 871bb57e025d1daa42524040f038819a6c19ceef Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 1 Aug 2019 15:26:00 +0200 Subject: [PATCH] TransactionAwareDataSourceProxy locally handles get/clearWarnings call Closes gh-23346 --- .../jdbc/datasource/TransactionAwareDataSourceProxy.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/TransactionAwareDataSourceProxy.java b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/TransactionAwareDataSourceProxy.java index 05e4d36d0d..97a2fdc951 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/TransactionAwareDataSourceProxy.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/TransactionAwareDataSourceProxy.java @@ -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. @@ -203,6 +203,10 @@ 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);