Avoid log statements between resource opening and returning

Issue: SPR-17559

(cherry picked from commit 7854b7ac40)
This commit is contained in:
Juergen Hoeller
2018-12-03 23:50:50 +01:00
parent 191a2d3f25
commit 9d504c8e1d
3 changed files with 7 additions and 12 deletions

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2018 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.
@@ -111,7 +111,6 @@ public abstract class DataSourceUtils {
Connection con = dataSource.getConnection(); Connection con = dataSource.getConnection();
if (TransactionSynchronizationManager.isSynchronizationActive()) { if (TransactionSynchronizationManager.isSynchronizationActive()) {
logger.debug("Registering transaction synchronization for JDBC Connection");
// Use same Connection for further JDBC actions within the transaction. // Use same Connection for further JDBC actions within the transaction.
// Thread-bound object will get removed by synchronization at transaction completion. // Thread-bound object will get removed by synchronization at transaction completion.
ConnectionHolder holderToUse = conHolder; ConnectionHolder holderToUse = conHolder;
@@ -326,7 +325,6 @@ public abstract class DataSourceUtils {
return; return;
} }
} }
logger.debug("Returning JDBC Connection to DataSource");
doCloseConnection(con, dataSource); doCloseConnection(con, dataSource);
} }

View File

@@ -148,7 +148,7 @@ public abstract class EntityManagerFactoryUtils {
* Obtain a JPA EntityManager from the given factory. Is aware of a corresponding * Obtain a JPA EntityManager from the given factory. Is aware of a corresponding
* EntityManager bound to the current thread, e.g. when using JpaTransactionManager. * EntityManager bound to the current thread, e.g. when using JpaTransactionManager.
* <p>Note: Will return {@code null} if no thread-bound EntityManager found! * <p>Note: Will return {@code null} if no thread-bound EntityManager found!
* @param emf EntityManagerFactory to create the EntityManager with * @param emf the EntityManagerFactory to create the EntityManager with
* @return the EntityManager, or {@code null} if none found * @return the EntityManager, or {@code null} if none found
* @throws DataAccessResourceFailureException if the EntityManager couldn't be obtained * @throws DataAccessResourceFailureException if the EntityManager couldn't be obtained
* @see JpaTransactionManager * @see JpaTransactionManager
@@ -163,7 +163,7 @@ public abstract class EntityManagerFactoryUtils {
* Obtain a JPA EntityManager from the given factory. Is aware of a corresponding * Obtain a JPA EntityManager from the given factory. Is aware of a corresponding
* EntityManager bound to the current thread, e.g. when using JpaTransactionManager. * EntityManager bound to the current thread, e.g. when using JpaTransactionManager.
* <p>Note: Will return {@code null} if no thread-bound EntityManager found! * <p>Note: Will return {@code null} if no thread-bound EntityManager found!
* @param emf EntityManagerFactory to create the EntityManager with * @param emf the EntityManagerFactory to create the EntityManager with
* @param properties the properties to be passed into the {@code createEntityManager} * @param properties the properties to be passed into the {@code createEntityManager}
* call (may be {@code null}) * call (may be {@code null})
* @return the EntityManager, or {@code null} if none found * @return the EntityManager, or {@code null} if none found
@@ -184,7 +184,7 @@ public abstract class EntityManagerFactoryUtils {
* Obtain a JPA EntityManager from the given factory. Is aware of a corresponding * Obtain a JPA EntityManager from the given factory. Is aware of a corresponding
* EntityManager bound to the current thread, e.g. when using JpaTransactionManager. * EntityManager bound to the current thread, e.g. when using JpaTransactionManager.
* <p>Same as {@code getEntityManager}, but throwing the original PersistenceException. * <p>Same as {@code getEntityManager}, but throwing the original PersistenceException.
* @param emf EntityManagerFactory to create the EntityManager with * @param emf the EntityManagerFactory to create the EntityManager with
* @param properties the properties to be passed into the {@code createEntityManager} * @param properties the properties to be passed into the {@code createEntityManager}
* call (may be {@code null}) * call (may be {@code null})
* @return the EntityManager, or {@code null} if none found * @return the EntityManager, or {@code null} if none found
@@ -202,7 +202,7 @@ public abstract class EntityManagerFactoryUtils {
* Obtain a JPA EntityManager from the given factory. Is aware of a corresponding * Obtain a JPA EntityManager from the given factory. Is aware of a corresponding
* EntityManager bound to the current thread, e.g. when using JpaTransactionManager. * EntityManager bound to the current thread, e.g. when using JpaTransactionManager.
* <p>Same as {@code getEntityManager}, but throwing the original PersistenceException. * <p>Same as {@code getEntityManager}, but throwing the original PersistenceException.
* @param emf EntityManagerFactory to create the EntityManager with * @param emf the EntityManagerFactory to create the EntityManager with
* @param properties the properties to be passed into the {@code createEntityManager} * @param properties the properties to be passed into the {@code createEntityManager}
* call (may be {@code null}) * call (may be {@code null})
* @param synchronizedWithTransaction whether to automatically join ongoing * @param synchronizedWithTransaction whether to automatically join ongoing
@@ -287,7 +287,6 @@ public abstract class EntityManagerFactoryUtils {
// Use same EntityManager for further JPA operations within the transaction. // Use same EntityManager for further JPA operations within the transaction.
// Thread-bound object will get removed by synchronization at transaction completion. // Thread-bound object will get removed by synchronization at transaction completion.
logger.debug("Registering transaction synchronization for JPA EntityManager");
emHolder = new EntityManagerHolder(em); emHolder = new EntityManagerHolder(em);
if (synchronizedWithTransaction) { if (synchronizedWithTransaction) {
Object transactionData = prepareTransaction(em, emf); Object transactionData = prepareTransaction(em, emf);
@@ -347,7 +346,7 @@ public abstract class EntityManagerFactoryUtils {
* Apply the current transaction timeout, if any, to the given JPA Query object. * Apply the current transaction timeout, if any, to the given JPA Query object.
* <p>This method sets the JPA 2.0 query hint "javax.persistence.query.timeout" accordingly. * <p>This method sets the JPA 2.0 query hint "javax.persistence.query.timeout" accordingly.
* @param query the JPA Query object * @param query the JPA Query object
* @param emf JPA EntityManagerFactory that the Query was created for * @param emf the JPA EntityManagerFactory that the Query was created for
*/ */
public static void applyTransactionTimeout(Query query, EntityManagerFactory emf) { public static void applyTransactionTimeout(Query query, EntityManagerFactory emf) {
EntityManagerHolder emHolder = (EntityManagerHolder) TransactionSynchronizationManager.getResource(emf); EntityManagerHolder emHolder = (EntityManagerHolder) TransactionSynchronizationManager.getResource(emf);
@@ -432,7 +431,6 @@ public abstract class EntityManagerFactoryUtils {
*/ */
public static void closeEntityManager(EntityManager em) { public static void closeEntityManager(EntityManager em) {
if (em != null) { if (em != null) {
logger.debug("Closing JPA EntityManager");
try { try {
if (em.isOpen()) { if (em.isOpen()) {
em.close(); em.close();

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2018 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.
@@ -127,7 +127,6 @@ public abstract class ConnectionFactoryUtils {
Connection con = cf.getConnection(); Connection con = cf.getConnection();
if (TransactionSynchronizationManager.isSynchronizationActive()) { if (TransactionSynchronizationManager.isSynchronizationActive()) {
logger.debug("Registering transaction synchronization for CCI Connection");
conHolder = new ConnectionHolder(con); conHolder = new ConnectionHolder(con);
conHolder.setSynchronizedWithTransaction(true); conHolder.setSynchronizedWithTransaction(true);
TransactionSynchronizationManager.registerSynchronization(new ConnectionSynchronization(conHolder, cf)); TransactionSynchronizationManager.registerSynchronization(new ConnectionSynchronization(conHolder, cf));