Skip to content

Commit 65e5c14

Browse files
committed
Polishing
1 parent 9596b70 commit 65e5c14

File tree

4 files changed

+53
-64
lines changed

4 files changed

+53
-64
lines changed

spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcTemplate.java

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ public int getMaxRows() {
263263
}
264264

265265
/**
266-
* Set the query timeout for statements that this JdbcTemplate executes.
266+
* Set the query timeout (seconds) for statements that this JdbcTemplate executes.
267267
* <p>Default is -1, indicating to use the JDBC driver's default
268268
* (i.e. to not pass a specific query timeout setting on the driver).
269269
* <p>Note: Any timeout specified here will be overridden by the remaining
@@ -276,7 +276,7 @@ public void setQueryTimeout(int queryTimeout) {
276276
}
277277

278278
/**
279-
* Return the query timeout for statements that this JdbcTemplate executes.
279+
* Return the query timeout (seconds) for statements that this JdbcTemplate executes.
280280
*/
281281
public int getQueryTimeout() {
282282
return this.queryTimeout;
@@ -422,7 +422,7 @@ public <T> T execute(StatementCallback<T> action) throws DataAccessException {
422422
}
423423

424424
@Override
425-
public void execute(final String sql) throws DataAccessException {
425+
public void execute(String sql) throws DataAccessException {
426426
if (logger.isDebugEnabled()) {
427427
logger.debug("Executing SQL statement [" + sql + "]");
428428
}
@@ -446,7 +446,7 @@ public String getSql() {
446446

447447
@Override
448448
@Nullable
449-
public <T> T query(final String sql, final ResultSetExtractor<T> rse) throws DataAccessException {
449+
public <T> T query(String sql, ResultSetExtractor<T> rse) throws DataAccessException {
450450
Assert.notNull(sql, "SQL must not be null");
451451
Assert.notNull(rse, "ResultSetExtractor must not be null");
452452
if (logger.isDebugEnabled()) {
@@ -542,7 +542,7 @@ public SqlRowSet queryForRowSet(String sql) throws DataAccessException {
542542
}
543543

544544
@Override
545-
public int update(final String sql) throws DataAccessException {
545+
public int update(String sql) throws DataAccessException {
546546
Assert.notNull(sql, "SQL must not be null");
547547
if (logger.isDebugEnabled()) {
548548
logger.debug("Executing SQL update [" + sql + "]");
@@ -568,7 +568,7 @@ public String getSql() {
568568
}
569569

570570
@Override
571-
public int[] batchUpdate(final String... sql) throws DataAccessException {
571+
public int[] batchUpdate(String... sql) throws DataAccessException {
572572
Assert.notEmpty(sql, "SQL array must not be empty");
573573
if (logger.isDebugEnabled()) {
574574
logger.debug("Executing SQL batch update of " + sql.length + " statements");
@@ -714,7 +714,7 @@ public <T> T execute(String sql, PreparedStatementCallback<T> action) throws Dat
714714
*/
715715
@Nullable
716716
public <T> T query(
717-
PreparedStatementCreator psc, @Nullable final PreparedStatementSetter pss, final ResultSetExtractor<T> rse)
717+
PreparedStatementCreator psc, @Nullable PreparedStatementSetter pss, ResultSetExtractor<T> rse)
718718
throws DataAccessException {
719719

720720
Assert.notNull(rse, "ResultSetExtractor must not be null");
@@ -964,7 +964,7 @@ public SqlRowSet queryForRowSet(String sql, @Nullable Object... args) throws Dat
964964
return result(query(sql, args, new SqlRowSetResultSetExtractor()));
965965
}
966966

967-
protected int update(final PreparedStatementCreator psc, @Nullable final PreparedStatementSetter pss)
967+
protected int update(PreparedStatementCreator psc, @Nullable PreparedStatementSetter pss)
968968
throws DataAccessException {
969969

970970
logger.debug("Executing prepared SQL update");
@@ -994,7 +994,7 @@ public int update(PreparedStatementCreator psc) throws DataAccessException {
994994
}
995995

996996
@Override
997-
public int update(final PreparedStatementCreator psc, final KeyHolder generatedKeyHolder)
997+
public int update(PreparedStatementCreator psc, KeyHolder generatedKeyHolder)
998998
throws DataAccessException {
999999

10001000
Assert.notNull(generatedKeyHolder, "KeyHolder must not be null");
@@ -1027,8 +1027,8 @@ public int update(String sql, @Nullable Object... args) throws DataAccessExcepti
10271027
}
10281028

10291029
@Override
1030-
public int[] batchUpdate(final PreparedStatementCreator psc, final BatchPreparedStatementSetter pss,
1031-
final KeyHolder generatedKeyHolder) throws DataAccessException {
1030+
public int[] batchUpdate(PreparedStatementCreator psc, BatchPreparedStatementSetter pss,
1031+
KeyHolder generatedKeyHolder) throws DataAccessException {
10321032

10331033
int[] result = execute(psc, getPreparedStatementCallback(pss, generatedKeyHolder));
10341034

@@ -1037,7 +1037,7 @@ public int[] batchUpdate(final PreparedStatementCreator psc, final BatchPrepared
10371037
}
10381038

10391039
@Override
1040-
public int[] batchUpdate(String sql, final BatchPreparedStatementSetter pss) throws DataAccessException {
1040+
public int[] batchUpdate(String sql, BatchPreparedStatementSetter pss) throws DataAccessException {
10411041
if (logger.isDebugEnabled()) {
10421042
logger.debug("Executing SQL batch update [" + sql + "]");
10431043
}
@@ -1057,7 +1057,7 @@ public int[] batchUpdate(String sql, List<Object[]> batchArgs) throws DataAccess
10571057
}
10581058

10591059
@Override
1060-
public int[] batchUpdate(String sql, List<Object[]> batchArgs, final int[] argTypes) throws DataAccessException {
1060+
public int[] batchUpdate(String sql, List<Object[]> batchArgs, int[] argTypes) throws DataAccessException {
10611061
if (batchArgs.isEmpty()) {
10621062
return new int[0];
10631063
}
@@ -1094,8 +1094,8 @@ public int getBatchSize() {
10941094
}
10951095

10961096
@Override
1097-
public <T> int[][] batchUpdate(String sql, final Collection<T> batchArgs, final int batchSize,
1098-
final ParameterizedPreparedStatementSetter<T> pss) throws DataAccessException {
1097+
public <T> int[][] batchUpdate(String sql, Collection<T> batchArgs, int batchSize,
1098+
ParameterizedPreparedStatementSetter<T> pss) throws DataAccessException {
10991099

11001100
if (logger.isDebugEnabled()) {
11011101
logger.debug("Executing SQL batch update [" + sql + "] with a batch size of " + batchSize);
@@ -1209,9 +1209,9 @@ public <T> T execute(String callString, CallableStatementCallback<T> action) thr
12091209
public Map<String, Object> call(CallableStatementCreator csc, List<SqlParameter> declaredParameters)
12101210
throws DataAccessException {
12111211

1212-
final List<SqlParameter> updateCountParameters = new ArrayList<>();
1213-
final List<SqlParameter> resultSetParameters = new ArrayList<>();
1214-
final List<SqlParameter> callParameters = new ArrayList<>();
1212+
List<SqlParameter> updateCountParameters = new ArrayList<>();
1213+
List<SqlParameter> resultSetParameters = new ArrayList<>();
1214+
List<SqlParameter> callParameters = new ArrayList<>();
12151215

12161216
for (SqlParameter parameter : declaredParameters) {
12171217
if (parameter.isResultsParameter()) {
@@ -1261,7 +1261,7 @@ protected Map<String, Object> extractReturnedResults(CallableStatement cs,
12611261
int rsIndex = 0;
12621262
int updateIndex = 0;
12631263
boolean moreResults;
1264-
if (!this.skipResultsProcessing) {
1264+
if (!isSkipResultsProcessing()) {
12651265
do {
12661266
if (updateCount == -1) {
12671267
if (resultSetParameters != null && resultSetParameters.size() > rsIndex) {
@@ -1270,7 +1270,7 @@ protected Map<String, Object> extractReturnedResults(CallableStatement cs,
12701270
rsIndex++;
12711271
}
12721272
else {
1273-
if (!this.skipUndeclaredResults) {
1273+
if (!isSkipUndeclaredResults()) {
12741274
String rsName = RETURN_RESULT_SET_PREFIX + (rsIndex + 1);
12751275
SqlReturnResultSet undeclaredRsParam = new SqlReturnResultSet(rsName, getColumnMapRowMapper());
12761276
if (logger.isTraceEnabled()) {
@@ -1289,7 +1289,7 @@ protected Map<String, Object> extractReturnedResults(CallableStatement cs,
12891289
updateIndex++;
12901290
}
12911291
else {
1292-
if (!this.skipUndeclaredResults) {
1292+
if (!isSkipUndeclaredResults()) {
12931293
String undeclaredName = RETURN_UPDATE_COUNT_PREFIX + (updateIndex + 1);
12941294
if (logger.isTraceEnabled()) {
12951295
logger.trace("Added default SqlReturnUpdateCount parameter named '" + undeclaredName + "'");

spring-jms/src/main/java/org/springframework/jms/core/JmsTemplate.java

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,9 @@
4747
/**
4848
* Helper class that simplifies synchronous JMS access code.
4949
*
50-
* <p>If you want to use dynamic destination creation, you must specify
51-
* the type of JMS destination to create, using the "pubSubDomain" property.
52-
* For other operations, this is not necessary. Point-to-Point (Queues) is the default
53-
* domain.
50+
* <p>If you want to use dynamic destination creation, you must specify the type of
51+
* JMS destination to create, using the "pubSubDomain" property. For other operations,
52+
* this is not necessary. Point-to-Point (Queues) is the default domain.
5453
*
5554
* <p>Default settings for JMS Sessions are "not transacted" and "auto-acknowledge".
5655
* As defined by the Jakarta EE specification, the transaction and acknowledgement
@@ -105,7 +104,6 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
105104
@Nullable
106105
private MessageConverter messageConverter;
107106

108-
109107
private boolean messageIdEnabled = true;
110108

111109
private boolean messageTimestampEnabled = true;
@@ -116,7 +114,6 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
116114

117115
private long deliveryDelay = -1;
118116

119-
120117
private boolean explicitQosEnabled = false;
121118

122119
private int deliveryMode = Message.DEFAULT_DELIVERY_MODE;
@@ -151,11 +148,8 @@ public JmsTemplate(ConnectionFactory connectionFactory) {
151148
}
152149

153150
/**
154-
* Initialize the default implementations for the template's strategies:
155-
* DynamicDestinationResolver and SimpleMessageConverter.
156-
* @see #setDestinationResolver
151+
* Initialize the default implementations for the template's strategies.
157152
* @see #setMessageConverter
158-
* @see org.springframework.jms.support.destination.DynamicDestinationResolver
159153
* @see org.springframework.jms.support.converter.SimpleMessageConverter
160154
*/
161155
protected void initDefaultStrategies() {
@@ -262,7 +256,6 @@ private MessageConverter getRequiredMessageConverter() throws IllegalStateExcept
262256
return converter;
263257
}
264258

265-
266259
/**
267260
* Set whether message IDs are enabled. Default is "true".
268261
* <p>This is only a hint to the JMS producer.
@@ -352,7 +345,6 @@ public long getDeliveryDelay() {
352345
return this.deliveryDelay;
353346
}
354347

355-
356348
/**
357349
* Set if the QOS values (deliveryMode, priority, timeToLive)
358350
* should be used for sending a message.
@@ -454,7 +446,7 @@ public int getPriority() {
454446
* Set the time-to-live of the message when sending.
455447
* <p>Since a default value may be defined administratively,
456448
* this is only used when "isExplicitQosEnabled" equals "true".
457-
* @param timeToLive the message's lifetime (in milliseconds)
449+
* @param timeToLive the message lifetime (in milliseconds)
458450
* @see #isExplicitQosEnabled
459451
* @see jakarta.jms.Message#DEFAULT_TIME_TO_LIVE
460452
* @see jakarta.jms.MessageProducer#send(jakarta.jms.Message, int, int, long)
@@ -472,14 +464,15 @@ public long getTimeToLive() {
472464

473465
/**
474466
* Configure the {@link ObservationRegistry} to use for recording JMS observations.
475-
* @param observationRegistry the observation registry to use.
467+
* @param observationRegistry the observation registry to use
476468
* @since 6.1
477469
* @see io.micrometer.jakarta9.instrument.jms.JmsInstrumentation
478470
*/
479471
public void setObservationRegistry(ObservationRegistry observationRegistry) {
480472
this.observationRegistry = observationRegistry;
481473
}
482474

475+
483476
//---------------------------------------------------------------------------------------
484477
// JmsOperations execute methods
485478
//---------------------------------------------------------------------------------------
@@ -699,8 +692,7 @@ public void convertAndSend(Object message, MessagePostProcessor postProcessor) t
699692
}
700693

701694
@Override
702-
public void convertAndSend(
703-
Destination destination, Object message, MessagePostProcessor postProcessor)
695+
public void convertAndSend(Destination destination, Object message, MessagePostProcessor postProcessor)
704696
throws JmsException {
705697

706698
send(destination, session -> {
@@ -710,8 +702,7 @@ public void convertAndSend(
710702
}
711703

712704
@Override
713-
public void convertAndSend(
714-
String destinationName, Object message, MessagePostProcessor postProcessor)
705+
public void convertAndSend(String destinationName, Object message, MessagePostProcessor postProcessor)
715706
throws JmsException {
716707

717708
send(destinationName, session -> {

spring-jms/src/main/java/org/springframework/jms/support/destination/JmsDestinationAccessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public abstract class JmsDestinationAccessor extends JmsAccessor {
6969
* @see org.springframework.jms.support.destination.JndiDestinationResolver
7070
*/
7171
public void setDestinationResolver(DestinationResolver destinationResolver) {
72-
Assert.notNull(destinationResolver, "'destinationResolver' must not be null");
72+
Assert.notNull(destinationResolver, "DestinationResolver must not be null");
7373
this.destinationResolver = destinationResolver;
7474
}
7575

spring-messaging/src/main/java/org/springframework/messaging/support/MessageHeaderAccessor.java

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,6 @@ public class MessageHeaderAccessor {
123123
@Nullable
124124
private IdGenerator idGenerator;
125125

126-
private MessageHeaderAccessor(@Nullable MessageHeaders headers) {
127-
this.headers = new MutableMessageHeaders(headers);
128-
}
129-
130126

131127
/**
132128
* A constructor to create new headers.
@@ -143,23 +139,8 @@ public MessageHeaderAccessor(@Nullable Message<?> message) {
143139
this(message != null ? message.getHeaders() : null);
144140
}
145141

146-
147-
/**
148-
* Create an instance from a plain {@link Map}.
149-
* @param map the raw headers
150-
* @since 6.2
151-
*/
152-
public static MessageHeaderAccessor fromMap(@Nullable Map<String, Object> map) {
153-
return fromMessageHeaders(new MessageHeaders(map));
154-
}
155-
156-
/**
157-
* Create an instance from an existing {@link MessageHeaders} instance.
158-
* @param headers the headers
159-
* @since 6.2
160-
*/
161-
public static MessageHeaderAccessor fromMessageHeaders(@Nullable MessageHeaders headers) {
162-
return new MessageHeaderAccessor(headers);
142+
private MessageHeaderAccessor(@Nullable MessageHeaders headers) {
143+
this.headers = new MutableMessageHeaders(headers);
163144
}
164145

165146

@@ -187,7 +168,7 @@ protected MessageHeaderAccessor createAccessor(Message<?> message) {
187168
* <p>When modifications are complete use {@link #setImmutable()} to prevent
188169
* further changes. The intended use case for this mechanism is initialization
189170
* of a Message within a single thread.
190-
* <p>By default this is set to {@code false}.
171+
* <p>By default, this is set to {@code false}.
191172
* @since 4.1
192173
*/
193174
public void setLeaveMutable(boolean leaveMutable) {
@@ -576,10 +557,27 @@ public String toString() {
576557

577558
// Static factory methods
578559

560+
/**
561+
* Create an instance from a plain {@link Map}.
562+
* @param map the raw headers
563+
* @since 6.2
564+
*/
565+
public static MessageHeaderAccessor fromMap(@Nullable Map<String, Object> map) {
566+
return fromMessageHeaders(new MessageHeaders(map));
567+
}
568+
569+
/**
570+
* Create an instance from an existing {@link MessageHeaders} instance.
571+
* @param headers the headers
572+
* @since 6.2
573+
*/
574+
public static MessageHeaderAccessor fromMessageHeaders(@Nullable MessageHeaders headers) {
575+
return new MessageHeaderAccessor(headers);
576+
}
577+
579578
/**
580579
* Return the original {@code MessageHeaderAccessor} used to create the headers
581-
* of the given {@code Message}, or {@code null} if that's not available or if
582-
* its type does not match the required type.
580+
* of the given {@code Message}, or {@code null} if that's not available.
583581
* <p>This is for cases where the existence of an accessor is strongly expected
584582
* (followed up with an assertion) or where an accessor will be created otherwise.
585583
* @param message the message to get an accessor for

0 commit comments

Comments
 (0)