diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AspectMetadata.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AspectMetadata.java index 64bb2fe1d0a..49e31e6beca 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AspectMetadata.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AspectMetadata.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/InstantiationModelAwarePointcutAdvisorImpl.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/InstantiationModelAwarePointcutAdvisorImpl.java index ea5705cf8e4..33af3adfc30 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/InstantiationModelAwarePointcutAdvisorImpl.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/InstantiationModelAwarePointcutAdvisorImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/ReflectiveAspectJAdvisorFactory.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/ReflectiveAspectJAdvisorFactory.java index f24e2ac7a0a..00e7ad567ef 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/ReflectiveAspectJAdvisorFactory.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/ReflectiveAspectJAdvisorFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-beans/src/jmh/java/org/springframework/beans/AbstractPropertyAccessorBenchmark.java b/spring-beans/src/jmh/java/org/springframework/beans/AbstractPropertyAccessorBenchmark.java index d71837d6b75..6cdd116b4cb 100644 --- a/spring-beans/src/jmh/java/org/springframework/beans/AbstractPropertyAccessorBenchmark.java +++ b/spring-beans/src/jmh/java/org/springframework/beans/AbstractPropertyAccessorBenchmark.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -61,16 +61,15 @@ public class AbstractPropertyAccessorBenchmark { this.propertyAccessor = new BeanWrapperImpl(this.target); } switch (this.customEditor) { - case "stringTrimmer" -> this.propertyAccessor.registerCustomEditor(String.class, - new StringTrimmerEditor(false)); - case "numberOnPath" -> this.propertyAccessor.registerCustomEditor(int.class, "array.somePath", - new CustomNumberEditor(Integer.class, false)); - case "numberOnNestedPath" -> this.propertyAccessor.registerCustomEditor(int.class, "array[0].somePath", - new CustomNumberEditor(Integer.class, false)); - case "numberOnType" -> this.propertyAccessor.registerCustomEditor(int.class, - new CustomNumberEditor(Integer.class, false)); + case "stringTrimmer" -> + this.propertyAccessor.registerCustomEditor(String.class, new StringTrimmerEditor(false)); + case "numberOnPath" -> + this.propertyAccessor.registerCustomEditor(int.class, "array.somePath", new CustomNumberEditor(Integer.class, false)); + case "numberOnNestedPath" -> + this.propertyAccessor.registerCustomEditor(int.class, "array[0].somePath", new CustomNumberEditor(Integer.class, false)); + case "numberOnType" -> + this.propertyAccessor.registerCustomEditor(int.class, new CustomNumberEditor(Integer.class, false)); } - } } @@ -94,4 +93,5 @@ public class AbstractPropertyAccessorBenchmark { this.array = array; } } + } diff --git a/spring-context-support/src/main/java/org/springframework/mail/javamail/MimeMessageHelper.java b/spring-context-support/src/main/java/org/springframework/mail/javamail/MimeMessageHelper.java index 23eaee1dd20..84400943ced 100644 --- a/spring-context-support/src/main/java/org/springframework/mail/javamail/MimeMessageHelper.java +++ b/spring-context-support/src/main/java/org/springframework/mail/javamail/MimeMessageHelper.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -353,8 +353,8 @@ public class MimeMessageHelper { rootMixedMultipart.addBodyPart(relatedBodyPart); setMimeMultiparts(rootMixedMultipart, nestedRelatedMultipart); } - default -> throw new IllegalArgumentException( - "Only multipart modes MIXED_RELATED, RELATED and NO supported"); + default -> + throw new IllegalArgumentException("Only multipart modes MIXED_RELATED, RELATED and NO supported"); } } diff --git a/spring-context/src/main/java/org/springframework/cache/annotation/CachingConfigurationSelector.java b/spring-context/src/main/java/org/springframework/cache/annotation/CachingConfigurationSelector.java index 1af81080ebb..b170593bdcb 100644 --- a/spring-context/src/main/java/org/springframework/cache/annotation/CachingConfigurationSelector.java +++ b/spring-context/src/main/java/org/springframework/cache/annotation/CachingConfigurationSelector.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-context/src/main/java/org/springframework/context/annotation/TypeFilterUtils.java b/spring-context/src/main/java/org/springframework/context/annotation/TypeFilterUtils.java index 4f02a7ebb12..6ffb77b42bf 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/TypeFilterUtils.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/TypeFilterUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -93,8 +93,8 @@ public abstract class TypeFilterUtils { environment, resourceLoader, registry); typeFilters.add(filter); } - default -> throw new IllegalArgumentException( - "Filter type not supported with Class value: " + filterType); + default -> + throw new IllegalArgumentException("Filter type not supported with Class value: " + filterType); } } @@ -102,8 +102,8 @@ public abstract class TypeFilterUtils { switch (filterType) { case ASPECTJ -> typeFilters.add(new AspectJTypeFilter(expression, resourceLoader.getClassLoader())); case REGEX -> typeFilters.add(new RegexPatternTypeFilter(Pattern.compile(expression))); - default -> throw new IllegalArgumentException( - "Filter type not supported with String pattern: " + filterType); + default -> + throw new IllegalArgumentException("Filter type not supported with String pattern: " + filterType); } } diff --git a/spring-context/src/main/java/org/springframework/format/datetime/standard/DateTimeFormatterRegistrar.java b/spring-context/src/main/java/org/springframework/format/datetime/standard/DateTimeFormatterRegistrar.java index 0d35e95cd4c..1a72d449493 100644 --- a/spring-context/src/main/java/org/springframework/format/datetime/standard/DateTimeFormatterRegistrar.java +++ b/spring-context/src/main/java/org/springframework/format/datetime/standard/DateTimeFormatterRegistrar.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-context/src/main/java/org/springframework/scheduling/annotation/AsyncConfigurationSelector.java b/spring-context/src/main/java/org/springframework/scheduling/annotation/AsyncConfigurationSelector.java index 0acc985d3ea..c7f50aed70a 100644 --- a/spring-context/src/main/java/org/springframework/scheduling/annotation/AsyncConfigurationSelector.java +++ b/spring-context/src/main/java/org/springframework/scheduling/annotation/AsyncConfigurationSelector.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,8 +46,8 @@ public class AsyncConfigurationSelector extends AdviceModeImportSelector new String[]{ProxyAsyncConfiguration.class.getName()}; - case ASPECTJ -> new String[]{ASYNC_EXECUTION_ASPECT_CONFIGURATION_CLASS_NAME}; + case PROXY -> new String[] {ProxyAsyncConfiguration.class.getName()}; + case ASPECTJ -> new String[] {ASYNC_EXECUTION_ASPECT_CONFIGURATION_CLASS_NAME}; }; } diff --git a/spring-core/src/main/java/org/springframework/asm/TypePath.java b/spring-core/src/main/java/org/springframework/asm/TypePath.java index be95d3a55fa..b7cf845e7a4 100644 --- a/spring-core/src/main/java/org/springframework/asm/TypePath.java +++ b/spring-core/src/main/java/org/springframework/asm/TypePath.java @@ -163,13 +163,22 @@ public final class TypePath { int length = getLength(); StringBuilder result = new StringBuilder(length * 2); for (int i = 0; i < length; ++i) { - switch (getStep(i)) { - case ARRAY_ELEMENT -> result.append('['); - case INNER_TYPE -> result.append('.'); - case WILDCARD_BOUND -> result.append('*'); - case TYPE_ARGUMENT -> result.append(getStepArgument(i)).append(';'); - default -> throw new AssertionError(); - } + switch (getStep(i)) { + case ARRAY_ELEMENT: + result.append('['); + break; + case INNER_TYPE: + result.append('.'); + break; + case WILDCARD_BOUND: + result.append('*'); + break; + case TYPE_ARGUMENT: + result.append(getStepArgument(i)).append(';'); + break; + default: + throw new AssertionError(); + } } return result.toString(); } diff --git a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationsScanner.java b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationsScanner.java index 88e65703a0e..5a2666d1b76 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationsScanner.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationsScanner.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-core/src/main/java/org/springframework/core/env/ProfilesParser.java b/spring-core/src/main/java/org/springframework/core/env/ProfilesParser.java index b8f030dd52a..8e1e7c5561c 100644 --- a/spring-core/src/main/java/org/springframework/core/env/ProfilesParser.java +++ b/spring-core/src/main/java/org/springframework/core/env/ProfilesParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-core/src/main/java/org/springframework/core/io/buffer/DataBufferUtils.java b/spring-core/src/main/java/org/springframework/core/io/buffer/DataBufferUtils.java index 73f4579c1a8..438d7bf082d 100644 --- a/spring-core/src/main/java/org/springframework/core/io/buffer/DataBufferUtils.java +++ b/spring-core/src/main/java/org/springframework/core/io/buffer/DataBufferUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -607,8 +607,10 @@ public abstract class DataBufferUtils { } private static NestedMatcher createMatcher(byte[] delimiter) { - Assert.isTrue(delimiter.length > 0, "Delimiter must not be empty"); - return switch (delimiter.length) { + // extract length due to Eclipse IDE compiler error in switch expression + int length = delimiter.length; + Assert.isTrue(length > 0, "Delimiter must not be empty"); + return switch (length) { case 1 -> (delimiter[0] == 10 ? SingleByteMatcher.NEWLINE_MATCHER : new SingleByteMatcher(delimiter)); case 2 -> new TwoByteMatcher(delimiter); default -> new KnuthMorrisPrattMatcher(delimiter); diff --git a/spring-core/src/main/java/org/springframework/util/concurrent/ListenableFutureCallbackRegistry.java b/spring-core/src/main/java/org/springframework/util/concurrent/ListenableFutureCallbackRegistry.java index 343e81c0716..e2a016cc6cb 100644 --- a/spring-core/src/main/java/org/springframework/util/concurrent/ListenableFutureCallbackRegistry.java +++ b/spring-core/src/main/java/org/springframework/util/concurrent/ListenableFutureCallbackRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpDivide.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpDivide.java index 7ade8deaee2..7ac8326eedf 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpDivide.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpDivide.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpMinus.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpMinus.java index 9d69f0a6fa0..1098e15897c 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpMinus.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpMinus.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpModulus.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpModulus.java index 3d229cedd68..a21d5caf529 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpModulus.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpModulus.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpMultiply.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpMultiply.java index 3db753c15a6..d86965acafb 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpMultiply.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpMultiply.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpPlus.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpPlus.java index f4ff34235f7..3bbf0615cdb 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpPlus.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpPlus.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/Selection.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/Selection.java index 63da77012cd..9daa3b94aa7 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/Selection.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/Selection.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-jcl/src/main/java/org/apache/commons/logging/LogAdapter.java b/spring-jcl/src/main/java/org/apache/commons/logging/LogAdapter.java index 5ba97293f38..8ae19384f5b 100644 --- a/spring-jcl/src/main/java/org/apache/commons/logging/LogAdapter.java +++ b/spring-jcl/src/main/java/org/apache/commons/logging/LogAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-jms/src/main/java/org/springframework/jms/support/converter/MarshallingMessageConverter.java b/spring-jms/src/main/java/org/springframework/jms/support/converter/MarshallingMessageConverter.java index a6cec5ce4eb..c3dd8389ae1 100644 --- a/spring-jms/src/main/java/org/springframework/jms/support/converter/MarshallingMessageConverter.java +++ b/spring-jms/src/main/java/org/springframework/jms/support/converter/MarshallingMessageConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-messaging/src/jmh/java/org/springframework/messaging/simp/broker/DefaultSubscriptionRegistryBenchmark.java b/spring-messaging/src/jmh/java/org/springframework/messaging/simp/broker/DefaultSubscriptionRegistryBenchmark.java index c80415c6fbb..ebce89c7086 100644 --- a/spring-messaging/src/jmh/java/org/springframework/messaging/simp/broker/DefaultSubscriptionRegistryBenchmark.java +++ b/spring-messaging/src/jmh/java/org/springframework/messaging/simp/broker/DefaultSubscriptionRegistryBenchmark.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -145,9 +145,8 @@ public class DefaultSubscriptionRegistryBenchmark { @Setup(Level.Trial) public void doSetup(ServerState serverState) { switch (this.contention) { - case "noSubscribers" -> { + case "noSubscribers" -> this.destination = "someDestination_withNoSubscribers_" + serverState.uniqueIdGenerator.incrementAndGet(); - } case "sameDestination" -> this.destination = serverState.destinationIds[0]; case "none" -> { int uniqueNumber = serverState.uniqueIdGenerator.getAndIncrement(); diff --git a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/annotation/support/RSocketFrameTypeMessageCondition.java b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/annotation/support/RSocketFrameTypeMessageCondition.java index fb09da86c14..865a0c0b09d 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/annotation/support/RSocketFrameTypeMessageCondition.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/annotation/support/RSocketFrameTypeMessageCondition.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -197,10 +197,10 @@ public class RSocketFrameTypeMessageCondition extends AbstractMessageCondition REQUEST_FNF_OR_RESPONSE_CONDITION; case 1 -> REQUEST_RESPONSE_CONDITION; case 2 -> REQUEST_STREAM_CONDITION; - default -> throw new IllegalStateException("Invalid cardinality: " + cardinalityOut); + default -> throw new IllegalStateException("Invalid response cardinality: " + cardinalityOut); }; case 2 -> REQUEST_CHANNEL_CONDITION; - default -> throw new IllegalStateException("Invalid cardinality: " + cardinalityIn); + default -> throw new IllegalStateException("Invalid request cardinality: " + cardinalityIn); }; } diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/SharedEntityManagerCreator.java b/spring-orm/src/main/java/org/springframework/orm/jpa/SharedEntityManagerCreator.java index 977b71de139..f0665ec7e68 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/SharedEntityManagerCreator.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/SharedEntityManagerCreator.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/vendor/EclipseLinkJpaVendorAdapter.java b/spring-orm/src/main/java/org/springframework/orm/jpa/vendor/EclipseLinkJpaVendorAdapter.java index 2ad8daaff30..d26bd1e67b5 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/vendor/EclipseLinkJpaVendorAdapter.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/vendor/EclipseLinkJpaVendorAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/vendor/HibernateJpaVendorAdapter.java b/spring-orm/src/main/java/org/springframework/orm/jpa/vendor/HibernateJpaVendorAdapter.java index 041f23da5fb..1af984c6fde 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/vendor/HibernateJpaVendorAdapter.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/vendor/HibernateJpaVendorAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-r2dbc/src/main/java/org/springframework/r2dbc/connection/R2dbcTransactionManager.java b/spring-r2dbc/src/main/java/org/springframework/r2dbc/connection/R2dbcTransactionManager.java index fdce9d94e4e..557427ecb6c 100644 --- a/spring-r2dbc/src/main/java/org/springframework/r2dbc/connection/R2dbcTransactionManager.java +++ b/spring-r2dbc/src/main/java/org/springframework/r2dbc/connection/R2dbcTransactionManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-test/src/main/java/org/springframework/mock/web/MockPageContext.java b/spring-test/src/main/java/org/springframework/mock/web/MockPageContext.java index a5feb9e7821..f4a1b9b0048 100644 --- a/spring-test/src/main/java/org/springframework/mock/web/MockPageContext.java +++ b/spring-test/src/main/java/org/springframework/mock/web/MockPageContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -173,19 +173,16 @@ public class MockPageContext extends PageContext { @Nullable public Object getAttribute(String name, int scope) { Assert.notNull(name, "Attribute name must not be null"); - switch (scope) { - case PAGE_SCOPE: - return getAttribute(name); - case REQUEST_SCOPE: - return this.request.getAttribute(name); - case SESSION_SCOPE: + return switch (scope) { + case PAGE_SCOPE -> getAttribute(name); + case REQUEST_SCOPE -> this.request.getAttribute(name); + case SESSION_SCOPE -> { HttpSession session = this.request.getSession(false); - return (session != null ? session.getAttribute(name) : null); - case APPLICATION_SCOPE: - return this.servletContext.getAttribute(name); - default: - throw new IllegalArgumentException("Invalid scope: " + scope); - } + yield (session != null ? session.getAttribute(name) : null); + } + case APPLICATION_SCOPE -> this.servletContext.getAttribute(name); + default -> throw new IllegalArgumentException("Invalid scope: " + scope); + }; } @Override @@ -250,19 +247,16 @@ public class MockPageContext extends PageContext { @Override public Enumeration getAttributeNamesInScope(int scope) { - switch (scope) { - case PAGE_SCOPE: - return getAttributeNames(); - case REQUEST_SCOPE: - return this.request.getAttributeNames(); - case SESSION_SCOPE: + return switch (scope) { + case PAGE_SCOPE -> getAttributeNames(); + case REQUEST_SCOPE -> this.request.getAttributeNames(); + case SESSION_SCOPE -> { HttpSession session = this.request.getSession(false); - return (session != null ? session.getAttributeNames() : Collections.emptyEnumeration()); - case APPLICATION_SCOPE: - return this.servletContext.getAttributeNames(); - default: - throw new IllegalArgumentException("Invalid scope: " + scope); - } + yield (session != null ? session.getAttributeNames() : Collections.emptyEnumeration()); + } + case APPLICATION_SCOPE -> this.servletContext.getAttributeNames(); + default -> throw new IllegalArgumentException("Invalid scope: " + scope); + }; } @Override diff --git a/spring-tx/src/main/java/org/springframework/transaction/HeuristicCompletionException.java b/spring-tx/src/main/java/org/springframework/transaction/HeuristicCompletionException.java index 1d661868df2..554ecf26305 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/HeuristicCompletionException.java +++ b/spring-tx/src/main/java/org/springframework/transaction/HeuristicCompletionException.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-tx/src/main/java/org/springframework/transaction/jta/SpringJtaSynchronizationAdapter.java b/spring-tx/src/main/java/org/springframework/transaction/jta/SpringJtaSynchronizationAdapter.java index 84f54c85a23..89c5b9a5eee 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/jta/SpringJtaSynchronizationAdapter.java +++ b/spring-tx/src/main/java/org/springframework/transaction/jta/SpringJtaSynchronizationAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -171,9 +171,12 @@ public class SpringJtaSynchronizationAdapter implements Synchronization { } // Call afterCompletion with the appropriate status indication. switch (status) { - case Status.STATUS_COMMITTED -> this.springSynchronization.afterCompletion(TransactionSynchronization.STATUS_COMMITTED); - case Status.STATUS_ROLLEDBACK -> this.springSynchronization.afterCompletion(TransactionSynchronization.STATUS_ROLLED_BACK); - default -> this.springSynchronization.afterCompletion(TransactionSynchronization.STATUS_UNKNOWN); + case Status.STATUS_COMMITTED -> + this.springSynchronization.afterCompletion(TransactionSynchronization.STATUS_COMMITTED); + case Status.STATUS_ROLLEDBACK -> + this.springSynchronization.afterCompletion(TransactionSynchronization.STATUS_ROLLED_BACK); + default -> + this.springSynchronization.afterCompletion(TransactionSynchronization.STATUS_UNKNOWN); } } diff --git a/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2Tokenizer.java b/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2Tokenizer.java index 75458f488a6..73e87eb0b8b 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2Tokenizer.java +++ b/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2Tokenizer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-web/src/main/java/org/springframework/web/client/DefaultResponseErrorHandler.java b/spring-web/src/main/java/org/springframework/web/client/DefaultResponseErrorHandler.java index 2ac7fac2acb..55165060d0a 100644 --- a/spring-web/src/main/java/org/springframework/web/client/DefaultResponseErrorHandler.java +++ b/spring-web/src/main/java/org/springframework/web/client/DefaultResponseErrorHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -164,9 +164,12 @@ public class DefaultResponseErrorHandler implements ResponseErrorHandler { String message = getErrorMessage(statusCode.value(), statusText, body, charset); switch (statusCode.series()) { - case CLIENT_ERROR -> throw HttpClientErrorException.create(message, statusCode, statusText, headers, body, charset); - case SERVER_ERROR -> throw HttpServerErrorException.create(message, statusCode, statusText, headers, body, charset); - default -> throw new UnknownHttpStatusCodeException(message, statusCode.value(), statusText, headers, body, charset); + case CLIENT_ERROR -> + throw HttpClientErrorException.create(message, statusCode, statusText, headers, body, charset); + case SERVER_ERROR -> + throw HttpServerErrorException.create(message, statusCode, statusText, headers, body, charset); + default -> + throw new UnknownHttpStatusCodeException(message, statusCode.value(), statusText, headers, body, charset); } } diff --git a/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockPageContext.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockPageContext.java index bab4b193947..e3976304882 100644 --- a/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockPageContext.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockPageContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -173,19 +173,16 @@ public class MockPageContext extends PageContext { @Nullable public Object getAttribute(String name, int scope) { Assert.notNull(name, "Attribute name must not be null"); - switch (scope) { - case PAGE_SCOPE: - return getAttribute(name); - case REQUEST_SCOPE: - return this.request.getAttribute(name); - case SESSION_SCOPE: + return switch (scope) { + case PAGE_SCOPE -> getAttribute(name); + case REQUEST_SCOPE -> this.request.getAttribute(name); + case SESSION_SCOPE -> { HttpSession session = this.request.getSession(false); - return (session != null ? session.getAttribute(name) : null); - case APPLICATION_SCOPE: - return this.servletContext.getAttribute(name); - default: - throw new IllegalArgumentException("Invalid scope: " + scope); - } + yield (session != null ? session.getAttribute(name) : null); + } + case APPLICATION_SCOPE -> this.servletContext.getAttribute(name); + default -> throw new IllegalArgumentException("Invalid scope: " + scope); + }; } @Override @@ -250,19 +247,16 @@ public class MockPageContext extends PageContext { @Override public Enumeration getAttributeNamesInScope(int scope) { - switch (scope) { - case PAGE_SCOPE: - return getAttributeNames(); - case REQUEST_SCOPE: - return this.request.getAttributeNames(); - case SESSION_SCOPE: + return switch (scope) { + case PAGE_SCOPE -> getAttributeNames(); + case REQUEST_SCOPE -> this.request.getAttributeNames(); + case SESSION_SCOPE -> { HttpSession session = this.request.getSession(false); - return (session != null ? session.getAttributeNames() : Collections.emptyEnumeration()); - case APPLICATION_SCOPE: - return this.servletContext.getAttributeNames(); - default: - throw new IllegalArgumentException("Invalid scope: " + scope); - } + yield (session != null ? session.getAttributeNames() : Collections.emptyEnumeration()); + } + case APPLICATION_SCOPE -> this.servletContext.getAttributeNames(); + default -> throw new IllegalArgumentException("Invalid scope: " + scope); + }; } @Override diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/ViewControllerBeanDefinitionParser.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/ViewControllerBeanDefinitionParser.java index 8660adf04c5..b2109def5dc 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/ViewControllerBeanDefinitionParser.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/ViewControllerBeanDefinitionParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -90,15 +90,15 @@ class ViewControllerBeanDefinitionParser implements BeanDefinitionParser { controller.getPropertyValues().add("statusCode", statusCode); } } - case "redirect-view-controller" -> controller.getPropertyValues() - .add("view", getRedirectView(element, statusCode, source)); + case "redirect-view-controller" -> + controller.getPropertyValues().add("view", getRedirectView(element, statusCode, source)); case "status-controller" -> { controller.getPropertyValues().add("statusCode", statusCode); controller.getPropertyValues().add("statusOnly", true); } default -> - // Should never happen... - throw new IllegalStateException("Unexpected tag name: " + name); + // Should never happen... + throw new IllegalStateException("Unexpected tag name: " + name); } Map urlMap = (Map) hm.getPropertyValues().get("urlMap"); diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/handler/ConcurrentWebSocketSessionDecorator.java b/spring-websocket/src/main/java/org/springframework/web/socket/handler/ConcurrentWebSocketSessionDecorator.java index 812b49d377b..5e538550a64 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/handler/ConcurrentWebSocketSessionDecorator.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/handler/ConcurrentWebSocketSessionDecorator.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -229,6 +229,9 @@ public class ConcurrentWebSocketSessionDecorator extends WebSocketSessionDecorat logger.debug("Dropped " + i + " messages, buffer size: " + getBufferSize()); } } + default -> + // Should never happen.. + throw new IllegalStateException("Unexpected OverflowStrategy: " + this.overflowStrategy); } } } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/AbstractSockJsSession.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/AbstractSockJsSession.java index 88944460944..9773f03a6d4 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/AbstractSockJsSession.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/AbstractSockJsSession.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -410,7 +410,7 @@ public abstract class AbstractSockJsSession implements SockJsSession { return switch (messages.length - i) { case 0 -> Collections.emptyList(); case 1 -> (messages[i].trim().isEmpty() ? - Collections.emptyList() : Collections.singletonList(messages[i])); + Collections.emptyList() : Collections.singletonList(messages[i])); default -> Arrays.stream(Arrays.copyOfRange(messages, i, messages.length)) .filter(message -> !message.trim().isEmpty()) .collect(Collectors.toList());