Browse Source

Polish contribution

See gh-29530
pull/29538/head
Sam Brannen 2 years ago
parent
commit
50109dd86d
  1. 2
      spring-web/src/main/java/org/springframework/http/client/HttpComponentsClientHttpRequestFactory.java
  2. 7
      spring-web/src/main/java/org/springframework/http/client/reactive/HttpComponentsClientHttpConnector.java
  3. 2
      spring-web/src/main/java/org/springframework/http/client/reactive/JettyHeadersAdapter.java
  4. 8
      spring-web/src/main/java/org/springframework/http/client/reactive/JettyResourceFactory.java
  5. 6
      spring-web/src/main/java/org/springframework/http/codec/DecoderHttpMessageReader.java
  6. 2
      spring-web/src/main/java/org/springframework/http/codec/ResourceHttpMessageWriter.java
  7. 6
      spring-web/src/main/java/org/springframework/http/codec/ServerSentEventHttpMessageWriter.java
  8. 4
      spring-web/src/main/java/org/springframework/http/codec/multipart/MultipartHttpMessageReader.java
  9. 2
      spring-web/src/main/java/org/springframework/http/codec/support/BaseCodecConfigurer.java
  10. 18
      spring-web/src/main/java/org/springframework/http/codec/support/BaseDefaultCodecs.java
  11. 6
      spring-web/src/main/java/org/springframework/http/converter/xml/MarshallingHttpMessageConverter.java
  12. 2
      spring-web/src/main/java/org/springframework/http/server/reactive/ChannelSendOperator.java
  13. 2
      spring-web/src/main/java/org/springframework/http/server/reactive/DefaultSslInfo.java
  14. 2
      spring-web/src/main/java/org/springframework/http/server/reactive/ServerHttpRequestDecorator.java
  15. 6
      spring-web/src/main/java/org/springframework/web/accept/ContentNegotiationManager.java
  16. 18
      spring-web/src/main/java/org/springframework/web/client/RestTemplate.java
  17. 2
      spring-web/src/main/java/org/springframework/web/context/ContextCleanupListener.java
  18. 2
      spring-web/src/main/java/org/springframework/web/context/support/AbstractRefreshableWebApplicationContext.java
  19. 2
      spring-web/src/main/java/org/springframework/web/context/support/ServletContextAwareProcessor.java
  20. 14
      spring-web/src/main/java/org/springframework/web/context/support/WebApplicationContextUtils.java
  21. 2
      spring-web/src/main/java/org/springframework/web/context/support/WebApplicationObjectSupport.java
  22. 2
      spring-web/src/main/java/org/springframework/web/jsf/DelegatingNavigationHandlerProxy.java
  23. 6
      spring-web/src/main/java/org/springframework/web/jsf/FacesContextUtils.java
  24. 2
      spring-web/src/main/java/org/springframework/web/method/ControllerAdviceBean.java
  25. 6
      spring-web/src/main/java/org/springframework/web/method/annotation/MapMethodProcessor.java
  26. 2
      spring-web/src/main/java/org/springframework/web/method/annotation/ModelAttributeMethodProcessor.java
  27. 2
      spring-web/src/main/java/org/springframework/web/method/annotation/ModelMethodProcessor.java
  28. 14
      spring-web/src/main/java/org/springframework/web/method/annotation/RequestParamMethodArgumentResolver.java
  29. 6
      spring-web/src/main/java/org/springframework/web/method/support/HandlerMethodReturnValueHandlerComposite.java
  30. 12
      spring-web/src/main/java/org/springframework/web/method/support/InvocableHandlerMethod.java
  31. 4
      spring-web/src/main/java/org/springframework/web/method/support/ModelAndViewContainer.java
  32. 8
      spring-web/src/main/java/org/springframework/web/multipart/MultipartFileResource.java
  33. 2
      spring-web/src/main/java/org/springframework/web/multipart/support/StandardServletMultipartResolver.java
  34. 2
      spring-web/src/main/java/org/springframework/web/server/adapter/WebHttpHandlerBuilder.java
  35. 14
      spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java
  36. 2
      spring-web/src/main/java/org/springframework/web/util/pattern/CaptureTheRestPathElement.java

2
spring-web/src/main/java/org/springframework/http/client/HttpComponentsClientHttpRequestFactory.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.

7
spring-web/src/main/java/org/springframework/http/client/reactive/HttpComponentsClientHttpConnector.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.
@ -158,10 +158,7 @@ public class HttpComponentsClientHttpConnector implements ClientHttpConnector, C @@ -158,10 +158,7 @@ public class HttpComponentsClientHttpConnector implements ClientHttpConnector, C
@Override
public void failed(Exception ex) {
Throwable t = ex;
if (t instanceof HttpStreamResetException hsre) {
t = hsre.getCause();
}
Throwable t = (ex instanceof HttpStreamResetException hsre ? hsre.getCause() : ex);
this.sink.error(t);
}

2
spring-web/src/main/java/org/springframework/http/client/reactive/JettyHeadersAdapter.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.

8
spring-web/src/main/java/org/springframework/http/client/reactive/JettyResourceFactory.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.
@ -131,9 +131,9 @@ public class JettyResourceFactory implements InitializingBean, DisposableBean { @@ -131,9 +131,9 @@ public class JettyResourceFactory implements InitializingBean, DisposableBean {
}
if (this.byteBufferPool == null) {
this.byteBufferPool = new MappedByteBufferPool(2048,
this.executor instanceof ThreadPool.SizedThreadPool sizedThreadPool
? sizedThreadPool.getMaxThreads() / 2
: ProcessorUtils.availableProcessors() * 2);
this.executor instanceof ThreadPool.SizedThreadPool sizedThreadPool ?
sizedThreadPool.getMaxThreads() / 2 :
ProcessorUtils.availableProcessors() * 2);
}
if (this.scheduler == null) {
this.scheduler = new ScheduledExecutorScheduler(name + "-scheduler", false);

6
spring-web/src/main/java/org/springframework/http/codec/DecoderHttpMessageReader.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.
@ -163,8 +163,8 @@ public class DecoderHttpMessageReader<T> implements HttpMessageReader<T> { @@ -163,8 +163,8 @@ public class DecoderHttpMessageReader<T> implements HttpMessageReader<T> {
protected Map<String, Object> getReadHints(ResolvableType actualType,
ResolvableType elementType, ServerHttpRequest request, ServerHttpResponse response) {
if (this.decoder instanceof HttpMessageDecoder<?> httpMethodDecoder) {
return httpMethodDecoder.getDecodeHints(actualType, elementType, request, response);
if (this.decoder instanceof HttpMessageDecoder<?> httpMessageDecoder) {
return httpMessageDecoder.getDecodeHints(actualType, elementType, request, response);
}
return Hints.none();
}

2
spring-web/src/main/java/org/springframework/http/codec/ResourceHttpMessageWriter.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.

6
spring-web/src/main/java/org/springframework/http/codec/ServerSentEventHttpMessageWriter.java

@ -150,9 +150,9 @@ public class ServerSentEventHttpMessageWriter implements HttpMessageWriter<Objec @@ -150,9 +150,9 @@ public class ServerSentEventHttpMessageWriter implements HttpMessageWriter<Objec
if (data == null) {
result = Flux.just(encodeText(sb + "\n", mediaType, factory));
}
else if (data instanceof String dataString) {
dataString = StringUtils.replace(dataString, "\n", "\ndata:");
result = Flux.just(encodeText(sb + dataString + "\n\n", mediaType, factory));
else if (data instanceof String text) {
text = StringUtils.replace(text, "\n", "\ndata:");
result = Flux.just(encodeText(sb + text + "\n\n", mediaType, factory));
}
else {
result = encodeEvent(sb, data, dataType, mediaType, factory, hints);

4
spring-web/src/main/java/org/springframework/http/codec/multipart/MultipartHttpMessageReader.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.
@ -129,7 +129,7 @@ public class MultipartHttpMessageReader extends LoggingCodecSupport @@ -129,7 +129,7 @@ public class MultipartHttpMessageReader extends LoggingCodecSupport
}
private List<Part> toList(Collection<Part> collection) {
return collection instanceof List<Part> partList ? partList : new ArrayList<>(collection);
return (collection instanceof List<Part> list ? list : new ArrayList<>(collection));
}
}

2
spring-web/src/main/java/org/springframework/http/codec/support/BaseCodecConfigurer.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.

18
spring-web/src/main/java/org/springframework/http/codec/support/BaseDefaultCodecs.java

@ -441,24 +441,26 @@ class BaseDefaultCodecs implements CodecConfigurer.DefaultCodecs, CodecConfigure @@ -441,24 +441,26 @@ class BaseDefaultCodecs implements CodecConfigurer.DefaultCodecs, CodecConfigure
if (codec instanceof AbstractDataBufferDecoder<?> abstractDataBufferDecoder) {
abstractDataBufferDecoder.setMaxInMemorySize(size);
}
// Pattern variables in the following if-blocks cannot be named the same as instance fields
// due to lacking support in Checkstyle: https://github.com/checkstyle/checkstyle/issues/10969
if (protobufPresent) {
if (codec instanceof ProtobufDecoder protobufDecoderCodec) {
protobufDecoderCodec.setMaxMessageSize(size);
if (codec instanceof ProtobufDecoder protobufDec) {
protobufDec.setMaxMessageSize(size);
}
}
if (kotlinSerializationCborPresent) {
if (codec instanceof KotlinSerializationCborDecoder kotlinSerializationCborDecoderCodec) {
kotlinSerializationCborDecoderCodec.setMaxInMemorySize(size);
if (codec instanceof KotlinSerializationCborDecoder kotlinSerializationCborDec) {
kotlinSerializationCborDec.setMaxInMemorySize(size);
}
}
if (kotlinSerializationJsonPresent) {
if (codec instanceof KotlinSerializationJsonDecoder kotlinSerializationJsonDecoderCodec) {
kotlinSerializationJsonDecoderCodec.setMaxInMemorySize(size);
if (codec instanceof KotlinSerializationJsonDecoder kotlinSerializationJsonDec) {
kotlinSerializationJsonDec.setMaxInMemorySize(size);
}
}
if (kotlinSerializationProtobufPresent) {
if (codec instanceof KotlinSerializationProtobufDecoder kotlinSerializationProtobufDecoderCodec) {
kotlinSerializationProtobufDecoderCodec.setMaxInMemorySize(size);
if (codec instanceof KotlinSerializationProtobufDecoder kotlinSerializationProtobufDec) {
kotlinSerializationProtobufDec.setMaxInMemorySize(size);
}
}
if (jackson2Present) {

6
spring-web/src/main/java/org/springframework/http/converter/xml/MarshallingHttpMessageConverter.java

@ -69,8 +69,10 @@ public class MarshallingHttpMessageConverter extends AbstractXmlHttpMessageConve @@ -69,8 +69,10 @@ public class MarshallingHttpMessageConverter extends AbstractXmlHttpMessageConve
public MarshallingHttpMessageConverter(Marshaller marshaller) {
Assert.notNull(marshaller, "Marshaller must not be null");
this.marshaller = marshaller;
if (marshaller instanceof Unmarshaller um) {
this.unmarshaller = um;
// The following pattern variable cannot be named "unmarshaller" due to lacking
// support in Checkstyle: https://github.com/checkstyle/checkstyle/issues/10969
if (marshaller instanceof Unmarshaller _unmarshaller) {
this.unmarshaller = _unmarshaller;
}
}

2
spring-web/src/main/java/org/springframework/http/server/reactive/ChannelSendOperator.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-web/src/main/java/org/springframework/http/server/reactive/DefaultSslInfo.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-web/src/main/java/org/springframework/http/server/reactive/ServerHttpRequestDecorator.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.

6
spring-web/src/main/java/org/springframework/web/accept/ContentNegotiationManager.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.
@ -180,8 +180,8 @@ public class ContentNegotiationManager implements ContentNegotiationStrategy, Me @@ -180,8 +180,8 @@ public class ContentNegotiationManager implements ContentNegotiationStrategy, Me
public Map<String, MediaType> getMediaTypeMappings() {
Map<String, MediaType> result = null;
for (MediaTypeFileExtensionResolver resolver : this.resolvers) {
if (resolver instanceof MappingMediaTypeFileExtensionResolver mappingMediaTypeFileExtensionResolver) {
Map<String, MediaType> map = mappingMediaTypeFileExtensionResolver.getMediaTypes();
if (resolver instanceof MappingMediaTypeFileExtensionResolver mappingResolver) {
Map<String, MediaType> map = mappingResolver.getMediaTypes();
if (CollectionUtils.isEmpty(map)) {
continue;
}

18
spring-web/src/main/java/org/springframework/web/client/RestTemplate.java

@ -321,8 +321,8 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat @@ -321,8 +321,8 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
* @since 4.3
*/
public void setDefaultUriVariables(Map<String, ?> uriVars) {
if (this.uriTemplateHandler instanceof DefaultUriBuilderFactory defaultUriVariables) {
defaultUriVariables.setDefaultUriVariables(uriVars);
if (this.uriTemplateHandler instanceof DefaultUriBuilderFactory factory) {
factory.setDefaultUriVariables(uriVars);
}
else {
throw new IllegalArgumentException(
@ -1002,7 +1002,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat @@ -1002,7 +1002,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
}
private boolean canReadResponse(Type responseType, HttpMessageConverter<?> converter) {
Class<?> responseClass = (responseType instanceof Class<?> type ? type : null);
Class<?> responseClass = (responseType instanceof Class<?> clazz ? clazz : null);
if (responseClass != null) {
return converter.canRead(responseClass, null);
}
@ -1052,7 +1052,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat @@ -1052,7 +1052,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
}
@Override
@SuppressWarnings("unchecked")
@SuppressWarnings({ "unchecked", "rawtypes" })
public void doWithRequest(ClientHttpRequest httpRequest) throws IOException {
super.doWithRequest(httpRequest);
Object requestBody = this.requestEntity.getBody();
@ -1068,15 +1068,15 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat @@ -1068,15 +1068,15 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
}
else {
Class<?> requestBodyClass = requestBody.getClass();
Type requestBodyType = (this.requestEntity instanceof RequestEntity<?> re ?
re.getType() : requestBodyClass);
// The following pattern variable cannot be named "requestEntity" due to lacking
// support in Checkstyle: https://github.com/checkstyle/checkstyle/issues/10969
Type requestBodyType = (this.requestEntity instanceof RequestEntity<?> _requestEntity ?
_requestEntity.getType() : requestBodyClass);
HttpHeaders httpHeaders = httpRequest.getHeaders();
HttpHeaders requestHeaders = this.requestEntity.getHeaders();
MediaType requestContentType = requestHeaders.getContentType();
for (HttpMessageConverter<?> messageConverter : getMessageConverters()) {
if (messageConverter instanceof GenericHttpMessageConverter) {
GenericHttpMessageConverter<Object> genericConverter =
(GenericHttpMessageConverter<Object>) messageConverter;
if (messageConverter instanceof GenericHttpMessageConverter genericConverter) {
if (genericConverter.canWrite(requestBodyType, requestBodyClass, requestContentType)) {
if (!requestHeaders.isEmpty()) {
requestHeaders.forEach((key, values) -> httpHeaders.put(key, new ArrayList<>(values)));

2
spring-web/src/main/java/org/springframework/web/context/ContextCleanupListener.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-web/src/main/java/org/springframework/web/context/support/AbstractRefreshableWebApplicationContext.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-web/src/main/java/org/springframework/web/context/support/ServletContextAwareProcessor.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.

14
spring-web/src/main/java/org/springframework/web/context/support/WebApplicationContextUtils.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.
@ -114,14 +114,14 @@ public abstract class WebApplicationContextUtils { @@ -114,14 +114,14 @@ public abstract class WebApplicationContextUtils {
if (attr == null) {
return null;
}
if (attr instanceof RuntimeException re) {
throw re;
if (attr instanceof RuntimeException runtimeException) {
throw runtimeException;
}
if (attr instanceof Error error) {
throw error;
}
if (attr instanceof Exception ex) {
throw new IllegalStateException(ex);
if (attr instanceof Exception exception) {
throw new IllegalStateException(exception);
}
if (!(attr instanceof WebApplicationContext wac)) {
throw new IllegalStateException("Context attribute is not of type WebApplicationContext: " + attr);
@ -152,12 +152,12 @@ public abstract class WebApplicationContextUtils { @@ -152,12 +152,12 @@ public abstract class WebApplicationContextUtils {
while (attrNames.hasMoreElements()) {
String attrName = attrNames.nextElement();
Object attrValue = sc.getAttribute(attrName);
if (attrValue instanceof WebApplicationContext) {
if (attrValue instanceof WebApplicationContext currentWac) {
if (wac != null) {
throw new IllegalStateException("No unique WebApplicationContext found: more than one " +
"DispatcherServlet registered with publishContext=true?");
}
wac = (WebApplicationContext) attrValue;
wac = currentWac;
}
}
}

2
spring-web/src/main/java/org/springframework/web/context/support/WebApplicationObjectSupport.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.

2
spring-web/src/main/java/org/springframework/web/jsf/DelegatingNavigationHandlerProxy.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-web/src/main/java/org/springframework/web/jsf/FacesContextUtils.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 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.
@ -55,8 +55,8 @@ public abstract class FacesContextUtils { @@ -55,8 +55,8 @@ public abstract class FacesContextUtils {
if (attr == null) {
return null;
}
if (attr instanceof RuntimeException re) {
throw re;
if (attr instanceof RuntimeException runtimeException) {
throw runtimeException;
}
if (attr instanceof Error error) {
throw error;

2
spring-web/src/main/java/org/springframework/web/method/ControllerAdviceBean.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.

6
spring-web/src/main/java/org/springframework/web/method/annotation/MapMethodProcessor.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.
@ -65,8 +65,8 @@ public class MapMethodProcessor implements HandlerMethodArgumentResolver, Handle @@ -65,8 +65,8 @@ public class MapMethodProcessor implements HandlerMethodArgumentResolver, Handle
public void handleReturnValue(@Nullable Object returnValue, MethodParameter returnType,
ModelAndViewContainer mavContainer, NativeWebRequest webRequest) throws Exception {
if (returnValue instanceof Map returnValueMap) {
mavContainer.addAllAttributes(returnValueMap);
if (returnValue instanceof Map map) {
mavContainer.addAllAttributes(map);
}
else if (returnValue != null) {
// should not happen

2
spring-web/src/main/java/org/springframework/web/method/annotation/ModelAttributeMethodProcessor.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-web/src/main/java/org/springframework/web/method/annotation/ModelMethodProcessor.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.

14
spring-web/src/main/java/org/springframework/web/method/annotation/RequestParamMethodArgumentResolver.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.
@ -234,8 +234,8 @@ public class RequestParamMethodArgumentResolver extends AbstractNamedValueMethod @@ -234,8 +234,8 @@ public class RequestParamMethodArgumentResolver extends AbstractNamedValueMethod
Assert.state(name != null, "Unresolvable parameter name");
parameter = parameter.nestedIfOptional();
if (value instanceof Optional<?> optionalValue) {
value = optionalValue.orElse(null);
if (value instanceof Optional<?> optional) {
value = optional.orElse(null);
}
if (value == null) {
@ -245,8 +245,8 @@ public class RequestParamMethodArgumentResolver extends AbstractNamedValueMethod @@ -245,8 +245,8 @@ public class RequestParamMethodArgumentResolver extends AbstractNamedValueMethod
}
builder.queryParam(name);
}
else if (value instanceof Collection<?> collectionValue) {
for (Object element : collectionValue) {
else if (value instanceof Collection<?> elements) {
for (Object element : elements) {
element = formatUriValue(conversionService, TypeDescriptor.nested(parameter, 1), element);
builder.queryParam(name, element);
}
@ -263,8 +263,8 @@ public class RequestParamMethodArgumentResolver extends AbstractNamedValueMethod @@ -263,8 +263,8 @@ public class RequestParamMethodArgumentResolver extends AbstractNamedValueMethod
if (value == null) {
return null;
}
else if (value instanceof String stringValue) {
return stringValue;
else if (value instanceof String string) {
return string;
}
else if (cs != null) {
return (String) cs.convert(value, sourceType, STRING_TYPE_DESCRIPTOR);

6
spring-web/src/main/java/org/springframework/web/method/support/HandlerMethodReturnValueHandlerComposite.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.
@ -94,8 +94,8 @@ public class HandlerMethodReturnValueHandlerComposite implements HandlerMethodRe @@ -94,8 +94,8 @@ public class HandlerMethodReturnValueHandlerComposite implements HandlerMethodRe
private boolean isAsyncReturnValue(@Nullable Object value, MethodParameter returnType) {
for (HandlerMethodReturnValueHandler handler : this.returnValueHandlers) {
if (handler instanceof AsyncHandlerMethodReturnValueHandler asyncHandlerMethodReturnValueHandler &&
asyncHandlerMethodReturnValueHandler.isAsyncReturnValue(value, returnType)) {
if (handler instanceof AsyncHandlerMethodReturnValueHandler asyncHandler &&
asyncHandler.isAsyncReturnValue(value, returnType)) {
return true;
}
}

12
spring-web/src/main/java/org/springframework/web/method/support/InvocableHandlerMethod.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.
@ -208,15 +208,15 @@ public class InvocableHandlerMethod extends HandlerMethod { @@ -208,15 +208,15 @@ public class InvocableHandlerMethod extends HandlerMethod {
}
catch (IllegalArgumentException ex) {
assertTargetBean(method, getBean(), args);
String text = (ex.getMessage() == null || ex.getCause() instanceof NullPointerException)
? "Illegal argument": ex.getMessage();
String text = (ex.getMessage() == null || ex.getCause() instanceof NullPointerException) ?
"Illegal argument" : ex.getMessage();
throw new IllegalStateException(formatInvokeError(text, args), ex);
}
catch (InvocationTargetException ex) {
// Unwrap for HandlerExceptionResolvers ...
Throwable targetException = ex.getTargetException();
if (targetException instanceof RuntimeException re) {
throw re;
Throwable targetException = ex.getCause();
if (targetException instanceof RuntimeException runtimeException) {
throw runtimeException;
}
else if (targetException instanceof Error error) {
throw error;

4
spring-web/src/main/java/org/springframework/web/method/support/ModelAndViewContainer.java

@ -40,7 +40,7 @@ import org.springframework.web.bind.support.SimpleSessionStatus; @@ -40,7 +40,7 @@ import org.springframework.web.bind.support.SimpleSessionStatus;
* <p>A default {@link Model} is automatically created at instantiation.
* An alternate model instance may be provided via {@link #setRedirectModel}
* for use in a redirect scenario. When {@link #setRedirectModelScenario} is set
* to {@code true} signalling a redirect scenario, the {@link #getModel()}
* to {@code true} signaling a redirect scenario, the {@link #getModel()}
* returns the redirect model instead of the default model.
*
* @author Rossen Stoyanchev
@ -106,7 +106,7 @@ public class ModelAndViewContainer { @@ -106,7 +106,7 @@ public class ModelAndViewContainer {
*/
@Nullable
public String getViewName() {
return (this.view instanceof String stringView ? stringView : null);
return (this.view instanceof String viewName ? viewName : null);
}
/**

8
spring-web/src/main/java/org/springframework/web/multipart/MultipartFileResource.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.
@ -88,9 +88,9 @@ class MultipartFileResource extends AbstractResource { @@ -88,9 +88,9 @@ class MultipartFileResource extends AbstractResource {
@Override
public boolean equals(@Nullable Object other) {
return (this == other || (other instanceof MultipartFileResource multipartFileResource &&
multipartFileResource.multipartFile.equals(this.multipartFile)));
public boolean equals(@Nullable Object obj) {
return (this == obj || (obj instanceof MultipartFileResource other &&
this.multipartFile.equals(other.multipartFile)));
}
@Override

2
spring-web/src/main/java/org/springframework/web/multipart/support/StandardServletMultipartResolver.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-web/src/main/java/org/springframework/web/server/adapter/WebHttpHandlerBuilder.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.

14
spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.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.
@ -726,8 +726,8 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable { @@ -726,8 +726,8 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
@Nullable
private String getQueryParamValue(@Nullable Object value) {
if (value != null) {
return (value instanceof Optional<?> optionalValue ?
optionalValue.map(Object::toString).orElse(null) :
return (value instanceof Optional<?> optional ?
optional.map(Object::toString).orElse(null) :
value.toString());
}
return null;
@ -740,12 +740,12 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable { @@ -740,12 +740,12 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
@Override
public UriComponentsBuilder queryParamIfPresent(String name, Optional<?> value) {
value.ifPresent(o -> {
if (o instanceof Collection<?> elements) {
queryParam(name, elements);
value.ifPresent(v -> {
if (v instanceof Collection<?> values) {
queryParam(name, values);
}
else {
queryParam(name, o);
queryParam(name, v);
}
});
return this;

2
spring-web/src/main/java/org/springframework/web/util/pattern/CaptureTheRestPathElement.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.

Loading…
Cancel
Save