Skip to content

Commit e336971

Browse files
committed
tweak
1 parent 31b41ee commit e336971

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

conjure-java-jaxrs-client/src/main/java/com/palantir/conjure/java/client/jaxrs/DialogueFeignClient.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
import java.io.OutputStream;
5353
import java.io.Reader;
5454
import java.io.StringReader;
55-
import java.io.UnsupportedEncodingException;
5655
import java.net.URLDecoder;
5756
import java.nio.charset.StandardCharsets;
5857
import java.util.Collection;
@@ -145,11 +144,7 @@ private static boolean includeRequestHeader(String headerName) {
145144
}
146145

147146
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);
153148
}
154149

155150
private static Optional<RequestBody> requestBody(Request request) {
@@ -242,12 +237,11 @@ public InputStream asInputStream() {
242237
@Override
243238
public Reader asReader() {
244239
Integer maybeLength = length();
245-
if (maybeLength != null && maybeLength.intValue() < 8192) {
240+
if (maybeLength != null && maybeLength < 8192) {
246241
// Avoid InputStreamReader / HeapByteBuffer overhead for small (less than 8KiB) inputs,
247242
// see https://github.com/FasterXML/jackson-core/pull/1081
248243
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));
251245
} catch (IOException e) {
252246
throw new SafeUncheckedIoException(
253247
"Failed to read response body", e, SafeArg.of("length", maybeLength));

0 commit comments

Comments
 (0)