Skip to content

Commit

Permalink
Polishing (aligned with main)
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoeller committed Dec 13, 2022
1 parent 064c618 commit 937ab5f
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,30 +69,30 @@ protected DataAccessException doTranslate(String task, @Nullable String sql, SQL
if (ex instanceof SQLTransientConnectionException) {
return new TransientDataAccessResourceException(buildMessage(task, sql, ex), ex);
}
else if (ex instanceof SQLTransactionRollbackException) {
if (ex instanceof SQLTransactionRollbackException) {
return new ConcurrencyFailureException(buildMessage(task, sql, ex), ex);
}
else if (ex instanceof SQLTimeoutException) {
if (ex instanceof SQLTimeoutException) {
return new QueryTimeoutException(buildMessage(task, sql, ex), ex);
}
}
else if (ex instanceof SQLNonTransientException) {
if (ex instanceof SQLNonTransientConnectionException) {
return new DataAccessResourceFailureException(buildMessage(task, sql, ex), ex);
}
else if (ex instanceof SQLDataException) {
if (ex instanceof SQLDataException) {
return new DataIntegrityViolationException(buildMessage(task, sql, ex), ex);
}
else if (ex instanceof SQLIntegrityConstraintViolationException) {
if (ex instanceof SQLIntegrityConstraintViolationException) {
return new DataIntegrityViolationException(buildMessage(task, sql, ex), ex);
}
else if (ex instanceof SQLInvalidAuthorizationSpecException) {
if (ex instanceof SQLInvalidAuthorizationSpecException) {
return new PermissionDeniedDataAccessException(buildMessage(task, sql, ex), ex);
}
else if (ex instanceof SQLSyntaxErrorException) {
if (ex instanceof SQLSyntaxErrorException) {
return new BadSqlGrammarException(task, (sql != null ? sql : ""), ex);
}
else if (ex instanceof SQLFeatureNotSupportedException) {
if (ex instanceof SQLFeatureNotSupportedException) {
return new InvalidDataAccessApiUsageException(buildMessage(task, sql, ex), ex);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 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.
Expand Down Expand Up @@ -221,7 +221,7 @@ public static DataAccessException convertR2dbcException(String task, @Nullable S
return new QueryTimeoutException(buildMessage(task, sql, ex), ex);
}
}
if (ex instanceof R2dbcNonTransientException) {
else if (ex instanceof R2dbcNonTransientException) {
if (ex instanceof R2dbcNonTransientResourceException) {
return new DataAccessResourceFailureException(buildMessage(task, sql, ex), ex);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2022 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.
Expand All @@ -20,6 +20,9 @@
* Exception thrown on failure to acquire a lock during an update,
* for example during a "select for update" statement.
*
* <p>Consider handling the general {@link PessimisticLockingFailureException}
* instead, semantically including a wider range of locking-related failures.
*
* @author Rod Johnson
*/
@SuppressWarnings("serial")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2022 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.
Expand All @@ -20,6 +20,9 @@
* Exception thrown on failure to complete a transaction in serialized mode
* due to update conflicts.
*
* <p>Consider handling the general {@link PessimisticLockingFailureException}
* instead, semantically including a wider range of locking-related failures.
*
* @author Rod Johnson
*/
@SuppressWarnings("serial")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2022 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.
Expand All @@ -19,17 +19,15 @@
import org.springframework.lang.Nullable;

/**
* Exception thrown on concurrency failure.
* Exception thrown on various data access concurrency failures.
*
* <p>This exception should be subclassed to indicate the type of failure:
* optimistic locking, failure to acquire lock, etc.
* <p>This exception provides subclasses for specific types of failure,
* in particular optimistic locking versus pessimistic locking.
*
* @author Thomas Risberg
* @since 1.1
* @see OptimisticLockingFailureException
* @see PessimisticLockingFailureException
* @see CannotAcquireLockException
* @see DeadlockLoserDataAccessException
*/
@SuppressWarnings("serial")
public class ConcurrencyFailureException extends TransientDataAccessException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@
/**
* Exception thrown when an attempt to insert or update data
* results in violation of an integrity constraint. Note that this
* is not purely a relational concept; unique primary keys are
* required by most database types.
* is not purely a relational concept; integrity constraints such
* as unique primary keys are required by most database types.
*
* <p>Serves as a superclass for more specific exceptions, e.g.
* {@link DuplicateKeyException}. However, it is generally
* recommended to handle {@code DataIntegrityViolationException}
* itself instead of relying on specific exception subclasses.
*
* @author Rod Johnson
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2022 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.
Expand All @@ -20,6 +20,9 @@
* Generic exception thrown when the current process was
* a deadlock loser, and its transaction rolled back.
*
* <p>Consider handling the general {@link PessimisticLockingFailureException}
* instead, semantically including a wider range of locking-related failures.
*
* @author Rod Johnson
*/
@SuppressWarnings("serial")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2022 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.
Expand All @@ -22,6 +22,9 @@
* Note that this is not necessarily a purely relational concept;
* unique primary keys are required by most database types.
*
* <p>Consider handling the general {@link DataIntegrityViolationException}
* instead, semantically including a wider range of constraint violations.
*
* @author Thomas Risberg
*/
@SuppressWarnings("serial")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2022 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.
Expand All @@ -21,13 +21,13 @@
* Thrown by Spring's SQLException translation mechanism
* if a corresponding database error is encountered.
*
* <p>Serves as superclass for more specific exceptions, like
* CannotAcquireLockException and DeadlockLoserDataAccessException.
* <p>Serves as a superclass for more specific exceptions, e.g.
* {@link CannotAcquireLockException}. However, it is generally
* recommended to handle {@code PessimisticLockingFailureException}
* itself instead of relying on specific exception subclasses.
*
* @author Thomas Risberg
* @since 1.2
* @see CannotAcquireLockException
* @see DeadlockLoserDataAccessException
* @see OptimisticLockingFailureException
*/
@SuppressWarnings("serial")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 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.
Expand Down Expand Up @@ -92,11 +92,11 @@ interface ClientDefaultCodecs extends DefaultCodecs {

/**
* Configure the {@code Decoder} to use for Server-Sent Events.
* <p>By default if this is not set, and Jackson is available, the
* {@link #jackson2JsonDecoder} override is used instead. Use this property
* if you want to further customize the SSE decoder.
* <p>Note that {@link #maxInMemorySize(int)}, if configured, will be
* applied to the given decoder.
* <p>By default if this is not set, and Jackson is available,
* the {@link #jackson2JsonDecoder} override is used instead.
* Use this method to customize the SSE decoder.
* <p>Note that {@link #maxInMemorySize(int)}, if configured,
* will be applied to the given decoder.
* @param decoder the decoder to use
*/
void serverSentEventDecoder(Decoder<?> decoder);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 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.
Expand Down Expand Up @@ -78,7 +78,7 @@ static ServerCodecConfigurer create() {


/**
* {@link CodecConfigurer.DefaultCodecs} extension with extra client-side options.
* {@link CodecConfigurer.DefaultCodecs} extension with extra server-side options.
*/
interface ServerDefaultCodecs extends DefaultCodecs {

Expand All @@ -101,9 +101,9 @@ interface ServerDefaultCodecs extends DefaultCodecs {

/**
* Configure the {@code Encoder} to use for Server-Sent Events.
* <p>By default if this is not set, and Jackson is available, the
* {@link #jackson2JsonEncoder} override is used instead. Use this method
* to customize the SSE encoder.
* <p>By default if this is not set, and Jackson is available,
* the {@link #jackson2JsonEncoder} override is used instead.
* Use this method to customize the SSE encoder.
*/
void serverSentEventEncoder(Encoder<?> encoder);
}
Expand Down

0 comments on commit 937ab5f

Please sign in to comment.