|
52 | 52 | import java.io.OutputStream; |
53 | 53 | import java.io.Reader; |
54 | 54 | import java.io.StringReader; |
55 | | -import java.io.UnsupportedEncodingException; |
56 | 55 | import java.net.URLDecoder; |
57 | 56 | import java.nio.charset.StandardCharsets; |
58 | 57 | import java.util.Collection; |
@@ -145,11 +144,7 @@ private static boolean includeRequestHeader(String headerName) { |
145 | 144 | } |
146 | 145 |
|
147 | 146 | private static String urlDecode(String input) { |
148 | | - try { |
149 | | - return URLDecoder.decode(input, "UTF-8"); |
150 | | - } catch (UnsupportedEncodingException e) { |
151 | | - throw new SafeRuntimeException("Failed to decode path segment", e, UnsafeArg.of("encoded", input)); |
152 | | - } |
| 147 | + return URLDecoder.decode(input, StandardCharsets.UTF_8); |
153 | 148 | } |
154 | 149 |
|
155 | 150 | private static Optional<RequestBody> requestBody(Request request) { |
@@ -242,12 +237,11 @@ public InputStream asInputStream() { |
242 | 237 | @Override |
243 | 238 | public Reader asReader() { |
244 | 239 | Integer maybeLength = length(); |
245 | | - if (maybeLength != null && maybeLength.intValue() < 8192) { |
| 240 | + if (maybeLength != null && maybeLength < 8192) { |
246 | 241 | // Avoid InputStreamReader / HeapByteBuffer overhead for small (less than 8KiB) inputs, |
247 | 242 | // see https://github.com/FasterXML/jackson-core/pull/1081 |
248 | 243 | try (InputStream inputStream = asInputStream()) { |
249 | | - String content = new String(inputStream.readAllBytes(), StandardCharsets.UTF_8); |
250 | | - return new StringReader(content); |
| 244 | + return new StringReader(new String(inputStream.readAllBytes(), StandardCharsets.UTF_8)); |
251 | 245 | } catch (IOException e) { |
252 | 246 | throw new SafeUncheckedIoException( |
253 | 247 | "Failed to read response body", e, SafeArg.of("length", maybeLength)); |
|
0 commit comments