From a80c5121fea0f6dc87dc9908c76dc592a9cb4b03 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 9 Jul 2018 15:53:44 +0200 Subject: [PATCH] Polishing --- .../SQLErrorCodeSQLExceptionTranslator.java | 34 +++++++++---------- .../orm/jpa/ExtendedEntityManagerCreator.java | 4 +-- .../orm/jpa/JpaTransactionManager.java | 6 ++-- .../dao/support/DataAccessUtils.java | 4 +-- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/support/SQLErrorCodeSQLExceptionTranslator.java b/spring-jdbc/src/main/java/org/springframework/jdbc/support/SQLErrorCodeSQLExceptionTranslator.java index 3824c100d11..6bb1056f45b 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/support/SQLErrorCodeSQLExceptionTranslator.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/support/SQLErrorCodeSQLExceptionTranslator.java @@ -180,9 +180,9 @@ public class SQLErrorCodeSQLExceptionTranslator extends AbstractFallbackSQLExcep } // First, try custom translation from overridden method. - DataAccessException dex = customTranslate(task, sql, sqlEx); - if (dex != null) { - return dex; + DataAccessException dae = customTranslate(task, sql, sqlEx); + if (dae != null) { + return dae; } // Next, try the custom SQLException translator, if available. @@ -288,15 +288,15 @@ public class SQLErrorCodeSQLExceptionTranslator extends AbstractFallbackSQLExcep } /** - * Subclasses can override this method to attempt a custom mapping from SQLException - * to DataAccessException. + * Subclasses can override this method to attempt a custom mapping from + * {@link SQLException} to {@link DataAccessException}. * @param task readable text describing the task being attempted - * @param sql the SQL query or update that caused the problem. May be {@code null}. + * @param sql the SQL query or update that caused the problem (may be {@code null}) * @param sqlEx the offending SQLException - * @return null if no custom translation was possible, otherwise a DataAccessException - * resulting from custom translation. This exception should include the sqlEx parameter - * as a nested root cause. This implementation always returns null, meaning that - * the translator always falls back to the default error codes. + * @return {@code null} if no custom translation applies, otherwise a {@link DataAccessException} + * resulting from custom translation. This exception should include the {@code sqlEx} parameter + * as a nested root cause. This implementation always returns {@code null}, meaning that the + * translator always falls back to the default error codes. */ @Nullable protected DataAccessException customTranslate(String task, @Nullable String sql, SQLException sqlEx) { @@ -304,16 +304,16 @@ public class SQLErrorCodeSQLExceptionTranslator extends AbstractFallbackSQLExcep } /** - * Create a custom DataAccessException, based on a given exception - * class from a CustomSQLErrorCodesTranslation definition. + * Create a custom {@link DataAccessException}, based on a given exception + * class from a {@link CustomSQLErrorCodesTranslation} definition. * @param task readable text describing the task being attempted - * @param sql the SQL query or update that caused the problem. May be {@code null}. + * @param sql the SQL query or update that caused the problem (may be {@code null}) * @param sqlEx the offending SQLException * @param exceptionClass the exception class to use, as defined in the - * CustomSQLErrorCodesTranslation definition - * @return null if the custom exception could not be created, otherwise - * the resulting DataAccessException. This exception should include the - * sqlEx parameter as a nested root cause. + * {@link CustomSQLErrorCodesTranslation} definition + * @return {@code null} if the custom exception could not be created, otherwise + * the resulting {@link DataAccessException}. This exception should include the + * {@code sqlEx} parameter as a nested root cause. * @see CustomSQLErrorCodesTranslation#setExceptionClass */ @Nullable diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/ExtendedEntityManagerCreator.java b/spring-orm/src/main/java/org/springframework/orm/jpa/ExtendedEntityManagerCreator.java index 0f2e0505d23..7914db8cde1 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/ExtendedEntityManagerCreator.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/ExtendedEntityManagerCreator.java @@ -491,10 +491,10 @@ public abstract class ExtendedEntityManagerCreator { } private RuntimeException convertException(RuntimeException ex) { - DataAccessException daex = (this.exceptionTranslator != null) ? + DataAccessException dae = (this.exceptionTranslator != null) ? this.exceptionTranslator.translateExceptionIfPossible(ex) : EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(ex); - return (daex != null ? daex : ex); + return (dae != null ? dae : ex); } } diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/JpaTransactionManager.java b/spring-orm/src/main/java/org/springframework/orm/jpa/JpaTransactionManager.java index f4aff717f09..99c6726d044 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/JpaTransactionManager.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/JpaTransactionManager.java @@ -533,9 +533,9 @@ public class JpaTransactionManager extends AbstractPlatformTransactionManager } catch (RollbackException ex) { if (ex.getCause() instanceof RuntimeException) { - DataAccessException dex = getJpaDialect().translateExceptionIfPossible((RuntimeException) ex.getCause()); - if (dex != null) { - throw dex; + DataAccessException dae = getJpaDialect().translateExceptionIfPossible((RuntimeException) ex.getCause()); + if (dae != null) { + throw dae; } } throw new TransactionSystemException("Could not commit JPA transaction", ex); diff --git a/spring-tx/src/main/java/org/springframework/dao/support/DataAccessUtils.java b/spring-tx/src/main/java/org/springframework/dao/support/DataAccessUtils.java index 9b3791e9147..5c2e126befa 100644 --- a/spring-tx/src/main/java/org/springframework/dao/support/DataAccessUtils.java +++ b/spring-tx/src/main/java/org/springframework/dao/support/DataAccessUtils.java @@ -239,8 +239,8 @@ public abstract class DataAccessUtils { RuntimeException rawException, PersistenceExceptionTranslator pet) { Assert.notNull(pet, "PersistenceExceptionTranslator must not be null"); - DataAccessException dex = pet.translateExceptionIfPossible(rawException); - return (dex != null ? dex : rawException); + DataAccessException dae = pet.translateExceptionIfPossible(rawException); + return (dae != null ? dae : rawException); } }