Skip to content

Commit 4765135

Browse files
committed
Polishing
1 parent 15c20c3 commit 4765135

File tree

5 files changed

+15
-21
lines changed

5 files changed

+15
-21
lines changed

Diff for: spring-beans/src/main/java/org/springframework/beans/AbstractNestablePropertyAccessor.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -291,18 +291,17 @@ private void processKeyedProperty(PropertyTokenHolder tokens, PropertyValue pv)
291291
String lastKey = tokens.keys[tokens.keys.length - 1];
292292

293293
if (propValue.getClass().isArray()) {
294-
Class<?> requiredType = propValue.getClass().componentType();
294+
Class<?> componentType = propValue.getClass().componentType();
295295
int arrayIndex = Integer.parseInt(lastKey);
296296
Object oldValue = null;
297297
try {
298298
if (isExtractOldValueForEditor() && arrayIndex < Array.getLength(propValue)) {
299299
oldValue = Array.get(propValue, arrayIndex);
300300
}
301301
Object convertedValue = convertIfNecessary(tokens.canonicalName, oldValue, pv.getValue(),
302-
requiredType, ph.nested(tokens.keys.length));
302+
componentType, ph.nested(tokens.keys.length));
303303
int length = Array.getLength(propValue);
304304
if (arrayIndex >= length && arrayIndex < this.autoGrowCollectionLimit) {
305-
Class<?> componentType = propValue.getClass().componentType();
306305
Object newArray = Array.newInstance(componentType, arrayIndex + 1);
307306
System.arraycopy(propValue, 0, newArray, 0, length);
308307
int lastKeyIndex = tokens.canonicalName.lastIndexOf('[');

Diff for: spring-jdbc/src/main/java/org/springframework/jdbc/core/SingleColumnRowMapper.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2025 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.
@@ -85,12 +85,13 @@ public void setRequiredType(Class<T> requiredType) {
8585
* Set a {@link ConversionService} for converting a fetched value.
8686
* <p>Default is the {@link DefaultConversionService}.
8787
* @since 5.0.4
88-
* @see DefaultConversionService#getSharedInstance
88+
* @see DefaultConversionService#getSharedInstance()
8989
*/
9090
public void setConversionService(@Nullable ConversionService conversionService) {
9191
this.conversionService = conversionService;
9292
}
9393

94+
9495
/**
9596
* Extract a value for the single column in the current row.
9697
* <p>Validates that there is only one column selected,

Diff for: spring-messaging/src/main/java/org/springframework/messaging/rsocket/service/DestinationVariableArgumentResolver.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2025 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.
@@ -48,8 +48,8 @@ public boolean resolve(
4848
collection.forEach(requestValues::addRouteVariable);
4949
return true;
5050
}
51-
else if (argument.getClass().isArray()) {
52-
for (Object variable : (Object[]) argument) {
51+
else if (argument instanceof Object[] arguments) {
52+
for (Object variable : arguments) {
5353
requestValues.addRouteVariable(variable);
5454
}
5555
return true;

Diff for: spring-web/src/main/java/org/springframework/web/client/DefaultRestClient.java

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 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.
@@ -150,6 +150,7 @@ final class DefaultRestClient implements RestClient {
150150
this.builder = builder;
151151
}
152152

153+
153154
@Override
154155
public RequestHeadersUriSpec<?> get() {
155156
return methodInternal(HttpMethod.GET);
@@ -283,8 +284,6 @@ private static <T> Class<T> bodyClass(Type type) {
283284
}
284285

285286

286-
287-
288287
private class DefaultRequestBodyUriSpec implements RequestBodyUriSpec {
289288

290289
private final HttpMethod httpMethod;
@@ -523,7 +522,6 @@ private void logBody(Object body, @Nullable MediaType mediaType, HttpMessageConv
523522
}
524523
}
525524

526-
527525
@Override
528526
public ResponseSpec retrieve() {
529527
return new DefaultResponseSpec(this);
@@ -832,7 +830,6 @@ private void applyStatusHandlers(HttpRequest request, ClientHttpResponse respons
832830
throw new UncheckedIOException(ex);
833831
}
834832
}
835-
836833
}
837834

838835

@@ -882,8 +879,6 @@ public String getStatusText() throws IOException {
882879
public void close() {
883880
this.delegate.close();
884881
}
885-
886882
}
887883

888-
889884
}

Diff for: spring-webmvc/src/main/java/org/springframework/web/servlet/tags/form/AbstractMultiCheckedElementTag.java

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2025 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.
@@ -217,11 +217,10 @@ protected int writeTagContent(TagWriter tagWriter) throws JspException {
217217
throw new IllegalArgumentException("Attribute 'items' is required and must be a Collection, an Array or a Map");
218218
}
219219

220-
if (itemsObject.getClass().isArray()) {
221-
Object[] itemsArray = (Object[]) itemsObject;
222-
for (int i = 0; i < itemsArray.length; i++) {
223-
Object item = itemsArray[i];
224-
writeObjectEntry(tagWriter, valueProperty, labelProperty, item, i);
220+
if (itemsObject instanceof Object[] itemsArray) {
221+
for (int itemIndex = 0; itemIndex < itemsArray.length; itemIndex++) {
222+
Object item = itemsArray[itemIndex];
223+
writeObjectEntry(tagWriter, valueProperty, labelProperty, item, itemIndex);
225224
}
226225
}
227226
else if (itemsObject instanceof Collection<?> optionCollection) {

0 commit comments

Comments
 (0)