Skip to content

Commit c050642

Browse files
committed
Polish contribution
See gh-30942
1 parent 7636eec commit c050642

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

spring-web/src/main/java/org/springframework/http/converter/StringHttpMessageConverter.java

Lines changed: 4 additions & 7 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-2023 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.
@@ -94,12 +94,9 @@ public boolean supports(Class<?> clazz) {
9494
protected String readInternal(Class<? extends String> clazz, HttpInputMessage inputMessage) throws IOException {
9595
Charset charset = getContentTypeCharset(inputMessage.getHeaders().getContentType());
9696
long length = inputMessage.getHeaders().getContentLength();
97-
final byte[] bytes;
98-
if (length >= 0 && length <= Integer.MAX_VALUE) {
99-
bytes = inputMessage.getBody().readNBytes((int) length);
100-
} else {
101-
bytes = inputMessage.getBody().readAllBytes();
102-
}
97+
byte[] bytes = (length >= 0 && length <= Integer.MAX_VALUE ?
98+
inputMessage.getBody().readNBytes((int) length) :
99+
inputMessage.getBody().readAllBytes());
103100
return new String(bytes, charset);
104101
}
105102

spring-web/src/test/java/org/springframework/http/converter/StringHttpMessageConverterTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2023 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.

0 commit comments

Comments
 (0)