Polish contribution

See gh-28014
This commit is contained in:
Sam Brannen 2022-02-19 14:32:57 +01:00
parent c5c926726d
commit 8c6d59aaaf
37 changed files with 132 additions and 125 deletions

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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;
}
}
}

View File

@ -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");
}
}

View File

@ -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.

View File

@ -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);
}
}

View File

@ -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.

View File

@ -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
@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};
};
}

View File

@ -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();
}

View File

@ -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.

View File

@ -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.

View File

@ -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);

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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();

View File

@ -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
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);
};
}

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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<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

View File

@ -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.

View File

@ -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);
}
}

View File

@ -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.

View File

@ -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);
}
}

View File

@ -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<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

View File

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

View File

@ -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);
}
}
}

View File

@ -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.<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());