Skip to content

Commit 8c6d59a

Browse files
committed
Polish contribution
See gh-28014
1 parent c5c9267 commit 8c6d59a

File tree

37 files changed

+132
-125
lines changed

37 files changed

+132
-125
lines changed

spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AspectMetadata.java

Lines changed: 1 addition & 1 deletion
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.

spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/InstantiationModelAwarePointcutAdvisorImpl.java

Lines changed: 1 addition & 1 deletion
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-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.

spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/ReflectiveAspectJAdvisorFactory.java

Lines changed: 1 addition & 1 deletion
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.

spring-beans/src/jmh/java/org/springframework/beans/AbstractPropertyAccessorBenchmark.java

Lines changed: 10 additions & 10 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.
@@ -61,16 +61,15 @@ public void setup() {
6161
this.propertyAccessor = new BeanWrapperImpl(this.target);
6262
}
6363
switch (this.customEditor) {
64-
case "stringTrimmer" -> this.propertyAccessor.registerCustomEditor(String.class,
65-
new StringTrimmerEditor(false));
66-
case "numberOnPath" -> this.propertyAccessor.registerCustomEditor(int.class, "array.somePath",
67-
new CustomNumberEditor(Integer.class, false));
68-
case "numberOnNestedPath" -> this.propertyAccessor.registerCustomEditor(int.class, "array[0].somePath",
69-
new CustomNumberEditor(Integer.class, false));
70-
case "numberOnType" -> this.propertyAccessor.registerCustomEditor(int.class,
71-
new CustomNumberEditor(Integer.class, false));
64+
case "stringTrimmer" ->
65+
this.propertyAccessor.registerCustomEditor(String.class, new StringTrimmerEditor(false));
66+
case "numberOnPath" ->
67+
this.propertyAccessor.registerCustomEditor(int.class, "array.somePath", new CustomNumberEditor(Integer.class, false));
68+
case "numberOnNestedPath" ->
69+
this.propertyAccessor.registerCustomEditor(int.class, "array[0].somePath", new CustomNumberEditor(Integer.class, false));
70+
case "numberOnType" ->
71+
this.propertyAccessor.registerCustomEditor(int.class, new CustomNumberEditor(Integer.class, false));
7272
}
73-
7473
}
7574

7675
}
@@ -94,4 +93,5 @@ public void setArray(int[] array) {
9493
this.array = array;
9594
}
9695
}
96+
9797
}

spring-context-support/src/main/java/org/springframework/mail/javamail/MimeMessageHelper.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-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.
@@ -353,8 +353,8 @@ protected void createMimeMultiparts(MimeMessage mimeMessage, int multipartMode)
353353
rootMixedMultipart.addBodyPart(relatedBodyPart);
354354
setMimeMultiparts(rootMixedMultipart, nestedRelatedMultipart);
355355
}
356-
default -> throw new IllegalArgumentException(
357-
"Only multipart modes MIXED_RELATED, RELATED and NO supported");
356+
default ->
357+
throw new IllegalArgumentException("Only multipart modes MIXED_RELATED, RELATED and NO supported");
358358
}
359359
}
360360

spring-context/src/main/java/org/springframework/cache/annotation/CachingConfigurationSelector.java

Lines changed: 1 addition & 1 deletion
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-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.

spring-context/src/main/java/org/springframework/context/annotation/TypeFilterUtils.java

Lines changed: 5 additions & 5 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-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.
@@ -93,17 +93,17 @@ public static List<TypeFilter> createTypeFiltersFor(AnnotationAttributes filterA
9393
environment, resourceLoader, registry);
9494
typeFilters.add(filter);
9595
}
96-
default -> throw new IllegalArgumentException(
97-
"Filter type not supported with Class value: " + filterType);
96+
default ->
97+
throw new IllegalArgumentException("Filter type not supported with Class value: " + filterType);
9898
}
9999
}
100100

101101
for (String expression : filterAttributes.getStringArray("pattern")) {
102102
switch (filterType) {
103103
case ASPECTJ -> typeFilters.add(new AspectJTypeFilter(expression, resourceLoader.getClassLoader()));
104104
case REGEX -> typeFilters.add(new RegexPatternTypeFilter(Pattern.compile(expression)));
105-
default -> throw new IllegalArgumentException(
106-
"Filter type not supported with String pattern: " + filterType);
105+
default ->
106+
throw new IllegalArgumentException("Filter type not supported with String pattern: " + filterType);
107107
}
108108
}
109109

spring-context/src/main/java/org/springframework/format/datetime/standard/DateTimeFormatterRegistrar.java

Lines changed: 1 addition & 1 deletion
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-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.

spring-context/src/main/java/org/springframework/scheduling/annotation/AsyncConfigurationSelector.java

Lines changed: 3 additions & 3 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-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.
@@ -46,8 +46,8 @@ public class AsyncConfigurationSelector extends AdviceModeImportSelector<EnableA
4646
@NonNull
4747
public String[] selectImports(AdviceMode adviceMode) {
4848
return switch (adviceMode) {
49-
case PROXY -> new String[]{ProxyAsyncConfiguration.class.getName()};
50-
case ASPECTJ -> new String[]{ASYNC_EXECUTION_ASPECT_CONFIGURATION_CLASS_NAME};
49+
case PROXY -> new String[] {ProxyAsyncConfiguration.class.getName()};
50+
case ASPECTJ -> new String[] {ASYNC_EXECUTION_ASPECT_CONFIGURATION_CLASS_NAME};
5151
};
5252
}
5353

spring-core/src/main/java/org/springframework/asm/TypePath.java

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,22 @@ public String toString() {
163163
int length = getLength();
164164
StringBuilder result = new StringBuilder(length * 2);
165165
for (int i = 0; i < length; ++i) {
166-
switch (getStep(i)) {
167-
case ARRAY_ELEMENT -> result.append('[');
168-
case INNER_TYPE -> result.append('.');
169-
case WILDCARD_BOUND -> result.append('*');
170-
case TYPE_ARGUMENT -> result.append(getStepArgument(i)).append(';');
171-
default -> throw new AssertionError();
172-
}
166+
switch (getStep(i)) {
167+
case ARRAY_ELEMENT:
168+
result.append('[');
169+
break;
170+
case INNER_TYPE:
171+
result.append('.');
172+
break;
173+
case WILDCARD_BOUND:
174+
result.append('*');
175+
break;
176+
case TYPE_ARGUMENT:
177+
result.append(getStepArgument(i)).append(';');
178+
break;
179+
default:
180+
throw new AssertionError();
181+
}
173182
}
174183
return result.toString();
175184
}

spring-core/src/main/java/org/springframework/core/annotation/AnnotationsScanner.java

Lines changed: 1 addition & 1 deletion
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-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.

spring-core/src/main/java/org/springframework/core/env/ProfilesParser.java

Lines changed: 1 addition & 1 deletion
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.

spring-core/src/main/java/org/springframework/core/io/buffer/DataBufferUtils.java

Lines changed: 5 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-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.
@@ -607,8 +607,10 @@ public static Matcher matcher(byte[]... delimiters) {
607607
}
608608

609609
private static NestedMatcher createMatcher(byte[] delimiter) {
610-
Assert.isTrue(delimiter.length > 0, "Delimiter must not be empty");
611-
return switch (delimiter.length) {
610+
// extract length due to Eclipse IDE compiler error in switch expression
611+
int length = delimiter.length;
612+
Assert.isTrue(length > 0, "Delimiter must not be empty");
613+
return switch (length) {
612614
case 1 -> (delimiter[0] == 10 ? SingleByteMatcher.NEWLINE_MATCHER : new SingleByteMatcher(delimiter));
613615
case 2 -> new TwoByteMatcher(delimiter);
614616
default -> new KnuthMorrisPrattMatcher(delimiter);

spring-core/src/main/java/org/springframework/util/concurrent/ListenableFutureCallbackRegistry.java

Lines changed: 1 addition & 1 deletion
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.

spring-expression/src/main/java/org/springframework/expression/spel/ast/OpDivide.java

Lines changed: 1 addition & 1 deletion
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-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.

spring-expression/src/main/java/org/springframework/expression/spel/ast/OpMinus.java

Lines changed: 1 addition & 1 deletion
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-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.

spring-expression/src/main/java/org/springframework/expression/spel/ast/OpModulus.java

Lines changed: 1 addition & 1 deletion
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-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.

spring-expression/src/main/java/org/springframework/expression/spel/ast/OpMultiply.java

Lines changed: 1 addition & 1 deletion
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-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.

spring-expression/src/main/java/org/springframework/expression/spel/ast/OpPlus.java

Lines changed: 1 addition & 1 deletion
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-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.

spring-expression/src/main/java/org/springframework/expression/spel/ast/Selection.java

Lines changed: 1 addition & 1 deletion
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.

spring-jcl/src/main/java/org/apache/commons/logging/LogAdapter.java

Lines changed: 1 addition & 1 deletion
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-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.

spring-jms/src/main/java/org/springframework/jms/support/converter/MarshallingMessageConverter.java

Lines changed: 1 addition & 1 deletion
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-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.

spring-messaging/src/jmh/java/org/springframework/messaging/simp/broker/DefaultSubscriptionRegistryBenchmark.java

Lines changed: 2 additions & 3 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.
@@ -145,9 +145,8 @@ public static class FindRequest {
145145
@Setup(Level.Trial)
146146
public void doSetup(ServerState serverState) {
147147
switch (this.contention) {
148-
case "noSubscribers" -> {
148+
case "noSubscribers" ->
149149
this.destination = "someDestination_withNoSubscribers_" + serverState.uniqueIdGenerator.incrementAndGet();
150-
}
151150
case "sameDestination" -> this.destination = serverState.destinationIds[0];
152151
case "none" -> {
153152
int uniqueNumber = serverState.uniqueIdGenerator.getAndIncrement();

spring-messaging/src/main/java/org/springframework/messaging/rsocket/annotation/support/RSocketFrameTypeMessageCondition.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-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.
@@ -197,10 +197,10 @@ public static RSocketFrameTypeMessageCondition getCondition(int cardinalityIn, i
197197
case 0 -> REQUEST_FNF_OR_RESPONSE_CONDITION;
198198
case 1 -> REQUEST_RESPONSE_CONDITION;
199199
case 2 -> REQUEST_STREAM_CONDITION;
200-
default -> throw new IllegalStateException("Invalid cardinality: " + cardinalityOut);
200+
default -> throw new IllegalStateException("Invalid response cardinality: " + cardinalityOut);
201201
};
202202
case 2 -> REQUEST_CHANNEL_CONDITION;
203-
default -> throw new IllegalStateException("Invalid cardinality: " + cardinalityIn);
203+
default -> throw new IllegalStateException("Invalid request cardinality: " + cardinalityIn);
204204
};
205205
}
206206

spring-orm/src/main/java/org/springframework/orm/jpa/SharedEntityManagerCreator.java

Lines changed: 1 addition & 1 deletion
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-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.

spring-orm/src/main/java/org/springframework/orm/jpa/vendor/EclipseLinkJpaVendorAdapter.java

Lines changed: 1 addition & 1 deletion
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-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.

spring-orm/src/main/java/org/springframework/orm/jpa/vendor/HibernateJpaVendorAdapter.java

Lines changed: 1 addition & 1 deletion
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-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.

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

Lines changed: 1 addition & 1 deletion
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-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.

spring-test/src/main/java/org/springframework/mock/web/MockPageContext.java

Lines changed: 19 additions & 25 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-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.
@@ -173,19 +173,16 @@ public Object getAttribute(String name) {
173173
@Nullable
174174
public Object getAttribute(String name, int scope) {
175175
Assert.notNull(name, "Attribute name must not be null");
176-
switch (scope) {
177-
case PAGE_SCOPE:
178-
return getAttribute(name);
179-
case REQUEST_SCOPE:
180-
return this.request.getAttribute(name);
181-
case SESSION_SCOPE:
176+
return switch (scope) {
177+
case PAGE_SCOPE -> getAttribute(name);
178+
case REQUEST_SCOPE -> this.request.getAttribute(name);
179+
case SESSION_SCOPE -> {
182180
HttpSession session = this.request.getSession(false);
183-
return (session != null ? session.getAttribute(name) : null);
184-
case APPLICATION_SCOPE:
185-
return this.servletContext.getAttribute(name);
186-
default:
187-
throw new IllegalArgumentException("Invalid scope: " + scope);
188-
}
181+
yield (session != null ? session.getAttribute(name) : null);
182+
}
183+
case APPLICATION_SCOPE -> this.servletContext.getAttribute(name);
184+
default -> throw new IllegalArgumentException("Invalid scope: " + scope);
185+
};
189186
}
190187

191188
@Override
@@ -250,19 +247,16 @@ public Enumeration<String> getAttributeNames() {
250247

251248
@Override
252249
public Enumeration<String> getAttributeNamesInScope(int scope) {
253-
switch (scope) {
254-
case PAGE_SCOPE:
255-
return getAttributeNames();
256-
case REQUEST_SCOPE:
257-
return this.request.getAttributeNames();
258-
case SESSION_SCOPE:
250+
return switch (scope) {
251+
case PAGE_SCOPE -> getAttributeNames();
252+
case REQUEST_SCOPE -> this.request.getAttributeNames();
253+
case SESSION_SCOPE -> {
259254
HttpSession session = this.request.getSession(false);
260-
return (session != null ? session.getAttributeNames() : Collections.emptyEnumeration());
261-
case APPLICATION_SCOPE:
262-
return this.servletContext.getAttributeNames();
263-
default:
264-
throw new IllegalArgumentException("Invalid scope: " + scope);
265-
}
255+
yield (session != null ? session.getAttributeNames() : Collections.emptyEnumeration());
256+
}
257+
case APPLICATION_SCOPE -> this.servletContext.getAttributeNames();
258+
default -> throw new IllegalArgumentException("Invalid scope: " + scope);
259+
};
266260
}
267261

268262
@Override

0 commit comments

Comments
 (0)