Skip to content

Commit 937ab5f

Browse files
committed
Polishing (aligned with main)
1 parent 064c618 commit 937ab5f

File tree

11 files changed

+52
-37
lines changed

11 files changed

+52
-37
lines changed

spring-jdbc/src/main/java/org/springframework/jdbc/support/SQLExceptionSubclassTranslator.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,30 +69,30 @@ protected DataAccessException doTranslate(String task, @Nullable String sql, SQL
6969
if (ex instanceof SQLTransientConnectionException) {
7070
return new TransientDataAccessResourceException(buildMessage(task, sql, ex), ex);
7171
}
72-
else if (ex instanceof SQLTransactionRollbackException) {
72+
if (ex instanceof SQLTransactionRollbackException) {
7373
return new ConcurrencyFailureException(buildMessage(task, sql, ex), ex);
7474
}
75-
else if (ex instanceof SQLTimeoutException) {
75+
if (ex instanceof SQLTimeoutException) {
7676
return new QueryTimeoutException(buildMessage(task, sql, ex), ex);
7777
}
7878
}
7979
else if (ex instanceof SQLNonTransientException) {
8080
if (ex instanceof SQLNonTransientConnectionException) {
8181
return new DataAccessResourceFailureException(buildMessage(task, sql, ex), ex);
8282
}
83-
else if (ex instanceof SQLDataException) {
83+
if (ex instanceof SQLDataException) {
8484
return new DataIntegrityViolationException(buildMessage(task, sql, ex), ex);
8585
}
86-
else if (ex instanceof SQLIntegrityConstraintViolationException) {
86+
if (ex instanceof SQLIntegrityConstraintViolationException) {
8787
return new DataIntegrityViolationException(buildMessage(task, sql, ex), ex);
8888
}
89-
else if (ex instanceof SQLInvalidAuthorizationSpecException) {
89+
if (ex instanceof SQLInvalidAuthorizationSpecException) {
9090
return new PermissionDeniedDataAccessException(buildMessage(task, sql, ex), ex);
9191
}
92-
else if (ex instanceof SQLSyntaxErrorException) {
92+
if (ex instanceof SQLSyntaxErrorException) {
9393
return new BadSqlGrammarException(task, (sql != null ? sql : ""), ex);
9494
}
95-
else if (ex instanceof SQLFeatureNotSupportedException) {
95+
if (ex instanceof SQLFeatureNotSupportedException) {
9696
return new InvalidDataAccessApiUsageException(buildMessage(task, sql, ex), ex);
9797
}
9898
}

spring-r2dbc/src/main/java/org/springframework/r2dbc/connection/ConnectionFactoryUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -221,7 +221,7 @@ public static DataAccessException convertR2dbcException(String task, @Nullable S
221221
return new QueryTimeoutException(buildMessage(task, sql, ex), ex);
222222
}
223223
}
224-
if (ex instanceof R2dbcNonTransientException) {
224+
else if (ex instanceof R2dbcNonTransientException) {
225225
if (ex instanceof R2dbcNonTransientResourceException) {
226226
return new DataAccessResourceFailureException(buildMessage(task, sql, ex), ex);
227227
}

spring-tx/src/main/java/org/springframework/dao/CannotAcquireLockException.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,6 +20,9 @@
2020
* Exception thrown on failure to acquire a lock during an update,
2121
* for example during a "select for update" statement.
2222
*
23+
* <p>Consider handling the general {@link PessimisticLockingFailureException}
24+
* instead, semantically including a wider range of locking-related failures.
25+
*
2326
* @author Rod Johnson
2427
*/
2528
@SuppressWarnings("serial")

spring-tx/src/main/java/org/springframework/dao/CannotSerializeTransactionException.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,6 +20,9 @@
2020
* Exception thrown on failure to complete a transaction in serialized mode
2121
* due to update conflicts.
2222
*
23+
* <p>Consider handling the general {@link PessimisticLockingFailureException}
24+
* instead, semantically including a wider range of locking-related failures.
25+
*
2326
* @author Rod Johnson
2427
*/
2528
@SuppressWarnings("serial")

spring-tx/src/main/java/org/springframework/dao/ConcurrencyFailureException.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,17 +19,15 @@
1919
import org.springframework.lang.Nullable;
2020

2121
/**
22-
* Exception thrown on concurrency failure.
22+
* Exception thrown on various data access concurrency failures.
2323
*
24-
* <p>This exception should be subclassed to indicate the type of failure:
25-
* optimistic locking, failure to acquire lock, etc.
24+
* <p>This exception provides subclasses for specific types of failure,
25+
* in particular optimistic locking versus pessimistic locking.
2626
*
2727
* @author Thomas Risberg
2828
* @since 1.1
2929
* @see OptimisticLockingFailureException
3030
* @see PessimisticLockingFailureException
31-
* @see CannotAcquireLockException
32-
* @see DeadlockLoserDataAccessException
3331
*/
3432
@SuppressWarnings("serial")
3533
public class ConcurrencyFailureException extends TransientDataAccessException {

spring-tx/src/main/java/org/springframework/dao/DataIntegrityViolationException.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,13 @@
1919
/**
2020
* Exception thrown when an attempt to insert or update data
2121
* results in violation of an integrity constraint. Note that this
22-
* is not purely a relational concept; unique primary keys are
23-
* required by most database types.
22+
* is not purely a relational concept; integrity constraints such
23+
* as unique primary keys are required by most database types.
24+
*
25+
* <p>Serves as a superclass for more specific exceptions, e.g.
26+
* {@link DuplicateKeyException}. However, it is generally
27+
* recommended to handle {@code DataIntegrityViolationException}
28+
* itself instead of relying on specific exception subclasses.
2429
*
2530
* @author Rod Johnson
2631
*/

spring-tx/src/main/java/org/springframework/dao/DeadlockLoserDataAccessException.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,6 +20,9 @@
2020
* Generic exception thrown when the current process was
2121
* a deadlock loser, and its transaction rolled back.
2222
*
23+
* <p>Consider handling the general {@link PessimisticLockingFailureException}
24+
* instead, semantically including a wider range of locking-related failures.
25+
*
2326
* @author Rod Johnson
2427
*/
2528
@SuppressWarnings("serial")

spring-tx/src/main/java/org/springframework/dao/DuplicateKeyException.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,6 +22,9 @@
2222
* Note that this is not necessarily a purely relational concept;
2323
* unique primary keys are required by most database types.
2424
*
25+
* <p>Consider handling the general {@link DataIntegrityViolationException}
26+
* instead, semantically including a wider range of constraint violations.
27+
*
2528
* @author Thomas Risberg
2629
*/
2730
@SuppressWarnings("serial")

spring-tx/src/main/java/org/springframework/dao/PessimisticLockingFailureException.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,13 +21,13 @@
2121
* Thrown by Spring's SQLException translation mechanism
2222
* if a corresponding database error is encountered.
2323
*
24-
* <p>Serves as superclass for more specific exceptions, like
25-
* CannotAcquireLockException and DeadlockLoserDataAccessException.
24+
* <p>Serves as a superclass for more specific exceptions, e.g.
25+
* {@link CannotAcquireLockException}. However, it is generally
26+
* recommended to handle {@code PessimisticLockingFailureException}
27+
* itself instead of relying on specific exception subclasses.
2628
*
2729
* @author Thomas Risberg
2830
* @since 1.2
29-
* @see CannotAcquireLockException
30-
* @see DeadlockLoserDataAccessException
3131
* @see OptimisticLockingFailureException
3232
*/
3333
@SuppressWarnings("serial")

spring-web/src/main/java/org/springframework/http/codec/ClientCodecConfigurer.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -92,11 +92,11 @@ interface ClientDefaultCodecs extends DefaultCodecs {
9292

9393
/**
9494
* Configure the {@code Decoder} to use for Server-Sent Events.
95-
* <p>By default if this is not set, and Jackson is available, the
96-
* {@link #jackson2JsonDecoder} override is used instead. Use this property
97-
* if you want to further customize the SSE decoder.
98-
* <p>Note that {@link #maxInMemorySize(int)}, if configured, will be
99-
* applied to the given decoder.
95+
* <p>By default if this is not set, and Jackson is available,
96+
* the {@link #jackson2JsonDecoder} override is used instead.
97+
* Use this method to customize the SSE decoder.
98+
* <p>Note that {@link #maxInMemorySize(int)}, if configured,
99+
* will be applied to the given decoder.
100100
* @param decoder the decoder to use
101101
*/
102102
void serverSentEventDecoder(Decoder<?> decoder);

spring-web/src/main/java/org/springframework/http/codec/ServerCodecConfigurer.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -78,7 +78,7 @@ static ServerCodecConfigurer create() {
7878

7979

8080
/**
81-
* {@link CodecConfigurer.DefaultCodecs} extension with extra client-side options.
81+
* {@link CodecConfigurer.DefaultCodecs} extension with extra server-side options.
8282
*/
8383
interface ServerDefaultCodecs extends DefaultCodecs {
8484

@@ -101,9 +101,9 @@ interface ServerDefaultCodecs extends DefaultCodecs {
101101

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

0 commit comments

Comments
 (0)