Skip to content

Commit 50109dd

Browse files
committed
Polish contribution
See gh-29530
1 parent 99ae209 commit 50109dd

36 files changed

+100
-99
lines changed

spring-web/src/main/java/org/springframework/http/client/HttpComponentsClientHttpRequestFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

spring-web/src/main/java/org/springframework/http/client/reactive/HttpComponentsClientHttpConnector.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -158,10 +158,7 @@ public void completed(Message<HttpResponse, Publisher<ByteBuffer>> result) {
158158

159159
@Override
160160
public void failed(Exception ex) {
161-
Throwable t = ex;
162-
if (t instanceof HttpStreamResetException hsre) {
163-
t = hsre.getCause();
164-
}
161+
Throwable t = (ex instanceof HttpStreamResetException hsre ? hsre.getCause() : ex);
165162
this.sink.error(t);
166163
}
167164

spring-web/src/main/java/org/springframework/http/client/reactive/JettyHeadersAdapter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

spring-web/src/main/java/org/springframework/http/client/reactive/JettyResourceFactory.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -131,9 +131,9 @@ public void afterPropertiesSet() throws Exception {
131131
}
132132
if (this.byteBufferPool == null) {
133133
this.byteBufferPool = new MappedByteBufferPool(2048,
134-
this.executor instanceof ThreadPool.SizedThreadPool sizedThreadPool
135-
? sizedThreadPool.getMaxThreads() / 2
136-
: ProcessorUtils.availableProcessors() * 2);
134+
this.executor instanceof ThreadPool.SizedThreadPool sizedThreadPool ?
135+
sizedThreadPool.getMaxThreads() / 2 :
136+
ProcessorUtils.availableProcessors() * 2);
137137
}
138138
if (this.scheduler == null) {
139139
this.scheduler = new ScheduledExecutorScheduler(name + "-scheduler", false);

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -163,8 +163,8 @@ public Mono<T> readMono(ResolvableType actualType, ResolvableType elementType,
163163
protected Map<String, Object> getReadHints(ResolvableType actualType,
164164
ResolvableType elementType, ServerHttpRequest request, ServerHttpResponse response) {
165165

166-
if (this.decoder instanceof HttpMessageDecoder<?> httpMethodDecoder) {
167-
return httpMethodDecoder.getDecodeHints(actualType, elementType, request, response);
166+
if (this.decoder instanceof HttpMessageDecoder<?> httpMessageDecoder) {
167+
return httpMessageDecoder.getDecodeHints(actualType, elementType, request, response);
168168
}
169169
return Hints.none();
170170
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@ private Flux<Publisher<DataBuffer>> encode(Publisher<?> input, ResolvableType el
150150
if (data == null) {
151151
result = Flux.just(encodeText(sb + "\n", mediaType, factory));
152152
}
153-
else if (data instanceof String dataString) {
154-
dataString = StringUtils.replace(dataString, "\n", "\ndata:");
155-
result = Flux.just(encodeText(sb + dataString + "\n\n", mediaType, factory));
153+
else if (data instanceof String text) {
154+
text = StringUtils.replace(text, "\n", "\ndata:");
155+
result = Flux.just(encodeText(sb + text + "\n\n", mediaType, factory));
156156
}
157157
else {
158158
result = encodeEvent(sb, data, dataType, mediaType, factory, hints);

spring-web/src/main/java/org/springframework/http/codec/multipart/MultipartHttpMessageReader.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -129,7 +129,7 @@ private LinkedMultiValueMap<String, Part> toMultiValueMap(Map<String, Collection
129129
}
130130

131131
private List<Part> toList(Collection<Part> collection) {
132-
return collection instanceof List<Part> partList ? partList : new ArrayList<>(collection);
132+
return (collection instanceof List<Part> list ? list : new ArrayList<>(collection));
133133
}
134134

135135
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -441,24 +441,26 @@ else if (codec instanceof EncoderHttpMessageWriter<?> encoderHttpMessageWriter)
441441
if (codec instanceof AbstractDataBufferDecoder<?> abstractDataBufferDecoder) {
442442
abstractDataBufferDecoder.setMaxInMemorySize(size);
443443
}
444+
// Pattern variables in the following if-blocks cannot be named the same as instance fields
445+
// due to lacking support in Checkstyle: https://github.com/checkstyle/checkstyle/issues/10969
444446
if (protobufPresent) {
445-
if (codec instanceof ProtobufDecoder protobufDecoderCodec) {
446-
protobufDecoderCodec.setMaxMessageSize(size);
447+
if (codec instanceof ProtobufDecoder protobufDec) {
448+
protobufDec.setMaxMessageSize(size);
447449
}
448450
}
449451
if (kotlinSerializationCborPresent) {
450-
if (codec instanceof KotlinSerializationCborDecoder kotlinSerializationCborDecoderCodec) {
451-
kotlinSerializationCborDecoderCodec.setMaxInMemorySize(size);
452+
if (codec instanceof KotlinSerializationCborDecoder kotlinSerializationCborDec) {
453+
kotlinSerializationCborDec.setMaxInMemorySize(size);
452454
}
453455
}
454456
if (kotlinSerializationJsonPresent) {
455-
if (codec instanceof KotlinSerializationJsonDecoder kotlinSerializationJsonDecoderCodec) {
456-
kotlinSerializationJsonDecoderCodec.setMaxInMemorySize(size);
457+
if (codec instanceof KotlinSerializationJsonDecoder kotlinSerializationJsonDec) {
458+
kotlinSerializationJsonDec.setMaxInMemorySize(size);
457459
}
458460
}
459461
if (kotlinSerializationProtobufPresent) {
460-
if (codec instanceof KotlinSerializationProtobufDecoder kotlinSerializationProtobufDecoderCodec) {
461-
kotlinSerializationProtobufDecoderCodec.setMaxInMemorySize(size);
462+
if (codec instanceof KotlinSerializationProtobufDecoder kotlinSerializationProtobufDec) {
463+
kotlinSerializationProtobufDec.setMaxInMemorySize(size);
462464
}
463465
}
464466
if (jackson2Present) {

0 commit comments

Comments
 (0)