Skip to content

Commit 3437e61

Browse files
committed
Merge branch '6.0.x'
2 parents 67e3d86 + 2573ba4 commit 3437e61

File tree

9 files changed

+62
-73
lines changed

9 files changed

+62
-73
lines changed

spring-context/src/main/java/org/springframework/scheduling/support/PeriodicTrigger.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
import java.time.Duration;
2020
import java.time.Instant;
2121
import java.time.temporal.ChronoUnit;
22-
import java.util.Objects;
2322
import java.util.concurrent.TimeUnit;
2423

2524
import org.springframework.lang.Nullable;
2625
import org.springframework.scheduling.Trigger;
2726
import org.springframework.scheduling.TriggerContext;
2827
import org.springframework.util.Assert;
28+
import org.springframework.util.ObjectUtils;
2929

3030
/**
3131
* A trigger for periodic task execution. The period may be applied as either
@@ -250,7 +250,7 @@ public boolean equals(@Nullable Object other) {
250250
return (this == other || (other instanceof PeriodicTrigger that &&
251251
this.fixedRate == that.fixedRate &&
252252
this.period.equals(that.period) &&
253-
Objects.equals(this.initialDelay, that.initialDelay)));
253+
ObjectUtils.nullSafeEquals(this.initialDelay, that.initialDelay)));
254254
}
255255

256256
@Override

spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/AbstractJdbcCall.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2023 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.
@@ -43,7 +43,7 @@
4343
* Abstract class to provide base functionality for easy stored procedure calls
4444
* based on configuration options and database meta-data.
4545
*
46-
* <p>This class provides the base SPI for {@link SimpleJdbcCall}.
46+
* <p>This class provides the processing arrangement for {@link SimpleJdbcCall}.
4747
*
4848
* @author Thomas Risberg
4949
* @author Juergen Hoeller
@@ -453,7 +453,7 @@ protected Map<String, Object> matchInParameterValuesWithCallParameters(SqlParame
453453
/**
454454
* Match the provided in parameter values with registered parameters and
455455
* parameters defined via meta-data processing.
456-
* @param args the parameter values provided in a Map
456+
* @param args the parameter values provided as a Map
457457
* @return a Map with parameter names and values
458458
*/
459459
protected Map<String, ?> matchInParameterValuesWithCallParameters(Map<String, ?> args) {

spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/AbstractJdbcInsert.java

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2023 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.
@@ -50,10 +50,10 @@
5050
import org.springframework.util.Assert;
5151

5252
/**
53-
* Abstract class to provide base functionality for easy inserts
53+
* Abstract class to provide base functionality for easy (batch) inserts
5454
* based on configuration options and database meta-data.
5555
*
56-
* <p>This class provides the base SPI for {@link SimpleJdbcInsert}.
56+
* <p>This class provides the processing arrangement for {@link SimpleJdbcInsert}.
5757
*
5858
* @author Thomas Risberg
5959
* @author Juergen Hoeller
@@ -409,7 +409,7 @@ protected KeyHolder doExecuteAndReturnKeyHolder(SqlParameterSource parameterSour
409409
/**
410410
* Delegate method to execute the insert, generating a single key.
411411
*/
412-
private Number executeInsertAndReturnKeyInternal(final List<?> values) {
412+
private Number executeInsertAndReturnKeyInternal(List<?> values) {
413413
KeyHolder kh = executeInsertAndReturnKeyHolderInternal(values);
414414
if (kh.getKey() != null) {
415415
return kh.getKey();
@@ -423,11 +423,11 @@ private Number executeInsertAndReturnKeyInternal(final List<?> values) {
423423
/**
424424
* Delegate method to execute the insert, generating any number of keys.
425425
*/
426-
private KeyHolder executeInsertAndReturnKeyHolderInternal(final List<?> values) {
426+
private KeyHolder executeInsertAndReturnKeyHolderInternal(List<?> values) {
427427
if (logger.isDebugEnabled()) {
428428
logger.debug("The following parameters are used for call " + getInsertString() + " with: " + values);
429429
}
430-
final KeyHolder keyHolder = new GeneratedKeyHolder();
430+
KeyHolder keyHolder = new GeneratedKeyHolder();
431431

432432
if (this.tableMetaDataContext.isGetGeneratedKeysSupported()) {
433433
getJdbcTemplate().update(
@@ -455,7 +455,7 @@ private KeyHolder executeInsertAndReturnKeyHolderInternal(final List<?> values)
455455
}
456456

457457
Assert.state(getTableName() != null, "No table name set");
458-
final String keyQuery = this.tableMetaDataContext.getSimpleQueryForGetGeneratedKey(
458+
String keyQuery = this.tableMetaDataContext.getSimpleQueryForGetGeneratedKey(
459459
getTableName(), getGeneratedKeyNames()[0]);
460460
Assert.state(keyQuery != null, "Query for simulating get generated keys must not be null");
461461

@@ -535,8 +535,8 @@ private PreparedStatement prepareStatementForGeneratedKeys(Connection con) throw
535535

536536
/**
537537
* Delegate method that executes a batch insert using the passed-in Maps of parameters.
538-
* @param batch array of Maps with parameter names and values to be used in batch insert
539-
* @return array of number of rows affected
538+
* @param batch maps with parameter names and values to be used in the batch insert
539+
* @return an array of number of rows affected
540540
*/
541541
@SuppressWarnings("unchecked")
542542
protected int[] doExecuteBatch(Map<String, ?>... batch) {
@@ -549,9 +549,10 @@ protected int[] doExecuteBatch(Map<String, ?>... batch) {
549549
}
550550

551551
/**
552-
* Delegate method that executes a batch insert using the passed-in {@link SqlParameterSource SqlParameterSources}.
553-
* @param batch array of SqlParameterSource with parameter names and values to be used in insert
554-
* @return array of number of rows affected
552+
* Delegate method that executes a batch insert using the passed-in
553+
* {@link SqlParameterSource SqlParameterSources}.
554+
* @param batch parameter sources with names and values to be used in the batch insert
555+
* @return an array of number of rows affected
555556
*/
556557
protected int[] doExecuteBatch(SqlParameterSource... batch) {
557558
checkCompiled();
@@ -606,7 +607,7 @@ private void setParameterValues(PreparedStatement preparedStatement, List<?> val
606607
* Match the provided in parameter values with registered parameters and parameters
607608
* defined via meta-data processing.
608609
* @param parameterSource the parameter values provided as a {@link SqlParameterSource}
609-
* @return a Map with parameter names and values
610+
* @return a List of values
610611
*/
611612
protected List<Object> matchInParameterValuesWithInsertColumns(SqlParameterSource parameterSource) {
612613
return this.tableMetaDataContext.matchInParameterValuesWithInsertColumns(parameterSource);
@@ -615,8 +616,8 @@ protected List<Object> matchInParameterValuesWithInsertColumns(SqlParameterSourc
615616
/**
616617
* Match the provided in parameter values with registered parameters and parameters
617618
* defined via meta-data processing.
618-
* @param args the parameter values provided in a Map
619-
* @return a Map with parameter names and values
619+
* @param args the parameter values provided as a Map
620+
* @return a List of values
620621
*/
621622
protected List<Object> matchInParameterValuesWithInsertColumns(Map<String, ?> args) {
622623
return this.tableMetaDataContext.matchInParameterValuesWithInsertColumns(args);

spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcCall.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2023 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.
@@ -47,7 +47,7 @@
4747
* any meta-data processing if you want to use parameter names that do not
4848
* match what is declared during the stored procedure compilation.
4949
*
50-
* <p>The actual insert is being handled using Spring's {@link JdbcTemplate}.
50+
* <p>The actual call is being handled using Spring's {@link JdbcTemplate}.
5151
*
5252
* <p>Many of the configuration methods return the current instance of the
5353
* SimpleJdbcCall in order to provide the ability to chain multiple ones

spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcInsert.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2023 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.
@@ -26,17 +26,17 @@
2626
import org.springframework.jdbc.support.KeyHolder;
2727

2828
/**
29-
* A SimpleJdbcInsert is a multithreaded, reusable object providing easy insert
29+
* A SimpleJdbcInsert is a multithreaded, reusable object providing easy (batch) insert
3030
* capabilities for a table. It provides meta-data processing to simplify the code
31-
* needed to construct a basic insert statement. All you need to provide is the
32-
* name of the table and a Map containing the column names and the column values.
31+
* needed to construct a basic insert statement. All you need to provide is the name
32+
* of the table and a Map containing the column names and the column values.
3333
*
3434
* <p>The meta-data processing is based on the DatabaseMetaData provided by the
3535
* JDBC driver. As long as the JDBC driver can provide the names of the columns
3636
* for a specified table then we can rely on this auto-detection feature. If that
3737
* is not the case, then the column names must be specified explicitly.
3838
*
39-
* <p>The actual insert is handled using Spring's {@link JdbcTemplate}.
39+
* <p>The actual (batch) insert is handled using Spring's {@link JdbcTemplate}.
4040
*
4141
* <p>Many of the configuration methods return the current instance of the
4242
* SimpleJdbcInsert to provide the ability to chain multiple ones together
@@ -142,8 +142,8 @@ public KeyHolder executeAndReturnKeyHolder(SqlParameterSource parameterSource) {
142142
return doExecuteAndReturnKeyHolder(parameterSource);
143143
}
144144

145-
@Override
146145
@SuppressWarnings("unchecked")
146+
@Override
147147
public int[] executeBatch(Map<String, ?>... batch) {
148148
return doExecuteBatch(batch);
149149
}

spring-r2dbc/src/main/java/org/springframework/r2dbc/core/DefaultDatabaseClient.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,17 @@
5757
import org.springframework.util.StringUtils;
5858

5959
/**
60-
* Default implementation of {@link DatabaseClient}.
60+
* The default implementation of {@link DatabaseClient},
61+
* as created by the static factory method.
6162
*
6263
* @author Mark Paluch
6364
* @author Mingyuan Wu
6465
* @author Bogdan Ilchyshyn
6566
* @author Simon Baslé
6667
* @since 5.3
68+
* @see DatabaseClient#create(ConnectionFactory)
6769
*/
68-
class DefaultDatabaseClient implements DatabaseClient {
70+
final class DefaultDatabaseClient implements DatabaseClient {
6971

7072
private final Log logger = LogFactory.getLog(getClass());
7173

@@ -251,11 +253,12 @@ public DefaultGenericExecuteSpec bind(int index, Object value) {
251253
"Value at index %d must not be null. Use bindNull(…) instead.", index));
252254

253255
Map<Integer, Parameter> byIndex = new LinkedHashMap<>(this.byIndex);
254-
if (value instanceof Parameter p) {
255-
byIndex.put(index, p);
256+
if (value instanceof Parameter param) {
257+
byIndex.put(index, param);
256258
}
257-
else if (value instanceof org.springframework.r2dbc.core.Parameter p) {
258-
byIndex.put(index, p.hasValue() ? Parameters.in(p.getValue()) : Parameters.in(p.getType()));
259+
else if (value instanceof org.springframework.r2dbc.core.Parameter param) {
260+
Object pv = param.getValue();
261+
byIndex.put(index, (pv != null ? Parameters.in(pv) : Parameters.in(param.getType())));
259262
}
260263
else {
261264
byIndex.put(index, Parameters.in(value));

spring-r2dbc/src/main/java/org/springframework/r2dbc/core/NamedParameterUtils.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import java.util.Iterator;
2323
import java.util.List;
2424
import java.util.Map;
25-
import java.util.Objects;
2625
import java.util.Set;
2726
import java.util.TreeMap;
2827

@@ -380,6 +379,7 @@ private static class ParameterHolder {
380379
private final int endIndex;
381380

382381
ParameterHolder(String parameterName, int startIndex, int endIndex) {
382+
Assert.notNull(parameterName, "Parameter name must not be null");
383383
this.parameterName = parameterName;
384384
this.startIndex = startIndex;
385385
this.endIndex = endIndex;
@@ -398,20 +398,15 @@ int getEndIndex() {
398398
}
399399

400400
@Override
401-
public boolean equals(@Nullable Object o) {
402-
if (this == o) {
403-
return true;
404-
}
405-
if (!(o instanceof ParameterHolder that)) {
406-
return false;
407-
}
408-
return this.startIndex == that.startIndex && this.endIndex == that.endIndex
409-
&& Objects.equals(this.parameterName, that.parameterName);
401+
public boolean equals(@Nullable Object other) {
402+
return (this == other || (other instanceof ParameterHolder that &&
403+
this.startIndex == that.startIndex && this.endIndex == that.endIndex &&
404+
this.parameterName.equals(that.parameterName)));
410405
}
411406

412407
@Override
413408
public int hashCode() {
414-
return Objects.hash(this.parameterName, this.startIndex, this.endIndex);
409+
return this.parameterName.hashCode();
415410
}
416411
}
417412

spring-r2dbc/src/main/java/org/springframework/r2dbc/core/Parameter.java

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
package org.springframework.r2dbc.core;
1818

19-
import java.util.Objects;
20-
2119
import org.springframework.lang.Nullable;
2220
import org.springframework.util.Assert;
2321
import org.springframework.util.ClassUtils;
@@ -111,20 +109,15 @@ public boolean isEmpty() {
111109

112110

113111
@Override
114-
public boolean equals(@Nullable Object obj) {
115-
if (this == obj) {
116-
return true;
117-
}
118-
if (!(obj instanceof Parameter other)) {
119-
return false;
120-
}
121-
return (ObjectUtils.nullSafeEquals(this.value, other.value) &&
122-
ObjectUtils.nullSafeEquals(this.type, other.type));
112+
public boolean equals(@Nullable Object other) {
113+
return (this == other || (other instanceof Parameter that &&
114+
ObjectUtils.nullSafeEquals(this.value, that.value) &&
115+
ObjectUtils.nullSafeEquals(this.type, that.type)));
123116
}
124117

125118
@Override
126119
public int hashCode() {
127-
return Objects.hash(this.value, this.type);
120+
return ObjectUtils.nullSafeHashCode(this.value) + ObjectUtils.nullSafeHashCode(this.type);
128121
}
129122

130123
@Override

0 commit comments

Comments
 (0)