Browse Source

Polish contribution

See gh-28014
pull/28094/head
Sam Brannen 3 years ago
parent
commit
8c6d59aaaf
  1. 2
      spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AspectMetadata.java
  2. 2
      spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/InstantiationModelAwarePointcutAdvisorImpl.java
  3. 2
      spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/ReflectiveAspectJAdvisorFactory.java
  4. 20
      spring-beans/src/jmh/java/org/springframework/beans/AbstractPropertyAccessorBenchmark.java
  5. 6
      spring-context-support/src/main/java/org/springframework/mail/javamail/MimeMessageHelper.java
  6. 2
      spring-context/src/main/java/org/springframework/cache/annotation/CachingConfigurationSelector.java
  7. 10
      spring-context/src/main/java/org/springframework/context/annotation/TypeFilterUtils.java
  8. 2
      spring-context/src/main/java/org/springframework/format/datetime/standard/DateTimeFormatterRegistrar.java
  9. 6
      spring-context/src/main/java/org/springframework/scheduling/annotation/AsyncConfigurationSelector.java
  10. 23
      spring-core/src/main/java/org/springframework/asm/TypePath.java
  11. 2
      spring-core/src/main/java/org/springframework/core/annotation/AnnotationsScanner.java
  12. 2
      spring-core/src/main/java/org/springframework/core/env/ProfilesParser.java
  13. 8
      spring-core/src/main/java/org/springframework/core/io/buffer/DataBufferUtils.java
  14. 2
      spring-core/src/main/java/org/springframework/util/concurrent/ListenableFutureCallbackRegistry.java
  15. 2
      spring-expression/src/main/java/org/springframework/expression/spel/ast/OpDivide.java
  16. 2
      spring-expression/src/main/java/org/springframework/expression/spel/ast/OpMinus.java
  17. 2
      spring-expression/src/main/java/org/springframework/expression/spel/ast/OpModulus.java
  18. 2
      spring-expression/src/main/java/org/springframework/expression/spel/ast/OpMultiply.java
  19. 2
      spring-expression/src/main/java/org/springframework/expression/spel/ast/OpPlus.java
  20. 2
      spring-expression/src/main/java/org/springframework/expression/spel/ast/Selection.java
  21. 2
      spring-jcl/src/main/java/org/apache/commons/logging/LogAdapter.java
  22. 2
      spring-jms/src/main/java/org/springframework/jms/support/converter/MarshallingMessageConverter.java
  23. 5
      spring-messaging/src/jmh/java/org/springframework/messaging/simp/broker/DefaultSubscriptionRegistryBenchmark.java
  24. 6
      spring-messaging/src/main/java/org/springframework/messaging/rsocket/annotation/support/RSocketFrameTypeMessageCondition.java
  25. 2
      spring-orm/src/main/java/org/springframework/orm/jpa/SharedEntityManagerCreator.java
  26. 2
      spring-orm/src/main/java/org/springframework/orm/jpa/vendor/EclipseLinkJpaVendorAdapter.java
  27. 2
      spring-orm/src/main/java/org/springframework/orm/jpa/vendor/HibernateJpaVendorAdapter.java
  28. 2
      spring-r2dbc/src/main/java/org/springframework/r2dbc/connection/R2dbcTransactionManager.java
  29. 44
      spring-test/src/main/java/org/springframework/mock/web/MockPageContext.java
  30. 2
      spring-tx/src/main/java/org/springframework/transaction/HeuristicCompletionException.java
  31. 11
      spring-tx/src/main/java/org/springframework/transaction/jta/SpringJtaSynchronizationAdapter.java
  32. 2
      spring-web/src/main/java/org/springframework/http/codec/json/Jackson2Tokenizer.java
  33. 11
      spring-web/src/main/java/org/springframework/web/client/DefaultResponseErrorHandler.java
  34. 44
      spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockPageContext.java
  35. 10
      spring-webmvc/src/main/java/org/springframework/web/servlet/config/ViewControllerBeanDefinitionParser.java
  36. 5
      spring-websocket/src/main/java/org/springframework/web/socket/handler/ConcurrentWebSocketSessionDecorator.java
  37. 4
      spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/AbstractSockJsSession.java

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

@ -1,5 +1,5 @@ @@ -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.

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

@ -1,5 +1,5 @@ @@ -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.

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

@ -1,5 +1,5 @@ @@ -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.

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

@ -1,5 +1,5 @@ @@ -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 { @@ -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 { @@ -94,4 +93,5 @@ public class AbstractPropertyAccessorBenchmark {
this.array = array;
}
}
}

6
spring-context-support/src/main/java/org/springframework/mail/javamail/MimeMessageHelper.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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");
}
}

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

@ -1,5 +1,5 @@ @@ -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.

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

@ -1,5 +1,5 @@ @@ -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 { @@ -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 { @@ -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);
}
}

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

@ -1,5 +1,5 @@ @@ -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.

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

@ -1,5 +1,5 @@ @@ -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<EnableA @@ -46,8 +46,8 @@ public class AsyncConfigurationSelector extends AdviceModeImportSelector<EnableA
@NonNull
public String[] selectImports(AdviceMode adviceMode) {
return switch (adviceMode) {
case PROXY -> 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};
};
}

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

@ -163,13 +163,22 @@ public final class TypePath { @@ -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();
}

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

@ -1,5 +1,5 @@ @@ -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.

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

@ -1,5 +1,5 @@ @@ -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.

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

@ -1,5 +1,5 @@ @@ -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 { @@ -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);

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

@ -1,5 +1,5 @@ @@ -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.

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

@ -1,5 +1,5 @@ @@ -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.

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

@ -1,5 +1,5 @@ @@ -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.

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

@ -1,5 +1,5 @@ @@ -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.

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

@ -1,5 +1,5 @@ @@ -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.

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

@ -1,5 +1,5 @@ @@ -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.

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

@ -1,5 +1,5 @@ @@ -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.

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

@ -1,5 +1,5 @@ @@ -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.

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

@ -1,5 +1,5 @@ @@ -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.

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

@ -1,5 +1,5 @@ @@ -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 { @@ -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();

6
spring-messaging/src/main/java/org/springframework/messaging/rsocket/annotation/support/RSocketFrameTypeMessageCondition.java

@ -1,5 +1,5 @@ @@ -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<R @@ -197,10 +197,10 @@ public class RSocketFrameTypeMessageCondition extends AbstractMessageCondition<R
case 0 -> 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);
};
}

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

@ -1,5 +1,5 @@ @@ -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.

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

@ -1,5 +1,5 @@ @@ -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.

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

@ -1,5 +1,5 @@ @@ -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.

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

@ -1,5 +1,5 @@ @@ -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.

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

@ -1,5 +1,5 @@ @@ -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 { @@ -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 { @@ -250,19 +247,16 @@ public class MockPageContext extends PageContext {
@Override
public Enumeration<String> 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

2
spring-tx/src/main/java/org/springframework/transaction/HeuristicCompletionException.java

@ -1,5 +1,5 @@ @@ -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.

11
spring-tx/src/main/java/org/springframework/transaction/jta/SpringJtaSynchronizationAdapter.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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);
}
}

2
spring-web/src/main/java/org/springframework/http/codec/json/Jackson2Tokenizer.java

@ -1,5 +1,5 @@ @@ -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.

11
spring-web/src/main/java/org/springframework/web/client/DefaultResponseErrorHandler.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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);
}
}

44
spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockPageContext.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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 { @@ -250,19 +247,16 @@ public class MockPageContext extends PageContext {
@Override
public Enumeration<String> 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

10
spring-webmvc/src/main/java/org/springframework/web/servlet/config/ViewControllerBeanDefinitionParser.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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<String, BeanDefinition> urlMap = (Map<String, BeanDefinition>) hm.getPropertyValues().get("urlMap");

5
spring-websocket/src/main/java/org/springframework/web/socket/handler/ConcurrentWebSocketSessionDecorator.java

@ -1,5 +1,5 @@ @@ -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 @@ -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);
}
}
}

4
spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/AbstractSockJsSession.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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.<String>emptyList() : Collections.singletonList(messages[i]));
Collections.<String>emptyList() : Collections.singletonList(messages[i]));
default -> Arrays.stream(Arrays.copyOfRange(messages, i, messages.length))
.filter(message -> !message.trim().isEmpty())
.collect(Collectors.toList());

Loading…
Cancel
Save