From 791a8e5c71d631160963208b96e93a2a7eb93822 Mon Sep 17 00:00:00 2001 From: Kevin Davis Date: Fri, 17 Jan 2020 21:09:25 -0500 Subject: [PATCH] Correct Encoding and restore decodeSlash in QueryTemplate (#1160) Fixes #1156 Collection Format was encoding query string values unnecessarily due to changes introduced in #1138 and #1139 that encode template values before appending them to the query string. In addition, `decodeSlash` flags that were accidentally removed, have been restored in QueryTemplate. * Restoring decodeSlash in QueryTemplate * Correcting Readme with regards to decodeSlash usage --- README.md | 4 +- .../benchmark/RealRequestBenchmarks.java | 8 +--- core/src/main/java/feign/Client.java | 1 - .../src/main/java/feign/CollectionFormat.java | 8 ++-- core/src/main/java/feign/RequestTemplate.java | 11 +++++- core/src/main/java/feign/Types.java | 3 +- core/src/main/java/feign/Util.java | 3 +- .../main/java/feign/stream/StreamDecoder.java | 3 +- .../main/java/feign/template/Expression.java | 3 +- .../java/feign/template/QueryTemplate.java | 37 ++++++++++++------- .../main/java/feign/template/UriUtils.java | 24 +++++++----- .../test/java/feign/RequestTemplateTest.java | 20 +++++++++- core/src/test/java/feign/TargetTest.java | 2 +- .../feign/assertj/RecordedRequestAssert.java | 3 +- .../feign/codec/DefaultErrorDecoderTest.java | 1 - .../java/feign/stream/StreamDecoderTest.java | 1 - .../feign/template/QueryTemplateTest.java | 8 ++-- .../java/feign/template/UriTemplateTest.java | 10 ++++- .../googlehttpclient/GoogleHttpClient.java | 1 - .../src/main/java/feign/gson/GsonDecoder.java | 1 - .../test/java/feign/gson/GsonCodecTest.java | 1 - .../java/feign/hc5/ApacheHttp5Client.java | 1 - .../feign/httpclient/ApacheHttpClient.java | 2 - .../httpclient/ApacheHttpClientTest.java | 4 +- .../jackson/jaxb/JacksonJaxbJsonDecoder.java | 3 +- .../java/feign/jackson/JacksonCodecTest.java | 2 - .../java/feign/jaxrs/JAXRSContractTest.java | 3 +- .../java/feign/reactive/ReactiveFeign.java | 3 +- .../src/main/java/feign/ribbon/LBClient.java | 1 - sax/src/main/java/feign/sax/SAXDecoder.java | 3 +- .../test/java/feign/soap/SOAPCodecTest.java | 1 - .../java/feign/spring/SpringContractTest.java | 3 +- 32 files changed, 98 insertions(+), 81 deletions(-) diff --git a/README.md b/README.md index a659e3c9af..bd411c2995 100644 --- a/README.md +++ b/README.md @@ -216,8 +216,8 @@ http://localhost:8080/test See [Advanced Usage](#advanced-usage) for more examples. > **What about slashes? `/`** -> -> @RequestLine and @QueryMap Templates do encode slash `/` characters by default. To change this behavior, set the `decodeSlash` property on the `@RequestLine` to `true`. +> +> @RequestLine templates do not encode slash `/` characters by default. To change this behavior, set the `decodeSlash` property on the `@RequestLine` to `false`. > **What about plus? `+`** > diff --git a/benchmark/src/main/java/feign/benchmark/RealRequestBenchmarks.java b/benchmark/src/main/java/feign/benchmark/RealRequestBenchmarks.java index 146b619d5c..9da45a442e 100644 --- a/benchmark/src/main/java/feign/benchmark/RealRequestBenchmarks.java +++ b/benchmark/src/main/java/feign/benchmark/RealRequestBenchmarks.java @@ -1,5 +1,5 @@ /** - * Copyright 2012-2019 The Feign Authors + * Copyright 2012-2020 The Feign Authors * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at @@ -20,17 +20,12 @@ import feign.Logger.Level; import feign.Response; import feign.Retryer; -import io.reactivex.netty.protocol.http.HttpHandlerNames; import io.reactivex.netty.protocol.http.server.HttpServer; -import io.reactivex.netty.protocol.http.server.HttpServerRequest; -import io.reactivex.netty.protocol.http.server.HttpServerResponse; -import io.reactivex.netty.protocol.http.server.RequestHandler; import java.io.IOException; import java.util.concurrent.TimeUnit; import io.netty.buffer.ByteBuf; import okhttp3.OkHttpClient; import okhttp3.Request; -import okhttp3.internal.http.HttpHeaders; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; @@ -42,7 +37,6 @@ import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Warmup; -import rx.Observable; @Measurement(iterations = 5, time = 1) @Warmup(iterations = 10, time = 1) diff --git a/core/src/main/java/feign/Client.java b/core/src/main/java/feign/Client.java index d1894e2488..fd6b35b41a 100644 --- a/core/src/main/java/feign/Client.java +++ b/core/src/main/java/feign/Client.java @@ -19,7 +19,6 @@ import static feign.Util.ENCODING_GZIP; import static feign.Util.checkArgument; import static feign.Util.checkNotNull; -import static feign.Util.isBlank; import static feign.Util.isNotBlank; import static java.lang.String.format; import java.io.IOException; diff --git a/core/src/main/java/feign/CollectionFormat.java b/core/src/main/java/feign/CollectionFormat.java index 5623c5aa6e..f38fdeda44 100644 --- a/core/src/main/java/feign/CollectionFormat.java +++ b/core/src/main/java/feign/CollectionFormat.java @@ -1,5 +1,5 @@ /** - * Copyright 2012-2019 The Feign Authors + * Copyright 2012-2020 The Feign Authors * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at @@ -77,7 +77,7 @@ public CharSequence join(String field, Collection values, Charset charse builder.append(UriUtils.encode(field, charset)); if (value != null) { builder.append('='); - builder.append(UriUtils.encode(value, charset)); + builder.append(value); } } else { // delimited with a separator character @@ -87,8 +87,8 @@ public CharSequence join(String field, Collection values, Charset charse if (value == null) { continue; } - builder.append(valueCount++ == 0 ? "=" : separator); - builder.append(UriUtils.encode(value, charset)); + builder.append(valueCount++ == 0 ? "=" : UriUtils.encode(separator, charset)); + builder.append(value); } } return builder; diff --git a/core/src/main/java/feign/RequestTemplate.java b/core/src/main/java/feign/RequestTemplate.java index dc5da50140..b9388f097d 100644 --- a/core/src/main/java/feign/RequestTemplate.java +++ b/core/src/main/java/feign/RequestTemplate.java @@ -327,6 +327,13 @@ public RequestTemplate decodeSlash(boolean decodeSlash) { this.decodeSlash = decodeSlash; this.uriTemplate = UriTemplate.create(this.uriTemplate.toString(), !this.decodeSlash, this.charset); + if (!this.queries.isEmpty()) { + this.queries.replaceAll((key, queryTemplate) -> QueryTemplate.create( + /* replace the current template with new ones honoring the decode value */ + queryTemplate.getName(), queryTemplate.getValues(), charset, collectionFormat, + decodeSlash)); + + } return this; } @@ -636,9 +643,9 @@ private RequestTemplate appendQuery(String name, /* create a new query template out of the information here */ this.queries.compute(name, (key, queryTemplate) -> { if (queryTemplate == null) { - return QueryTemplate.create(name, values, this.charset, collectionFormat); + return QueryTemplate.create(name, values, this.charset, collectionFormat, this.decodeSlash); } else { - return QueryTemplate.append(queryTemplate, values, collectionFormat); + return QueryTemplate.append(queryTemplate, values, collectionFormat, this.decodeSlash); } }); return this; diff --git a/core/src/main/java/feign/Types.java b/core/src/main/java/feign/Types.java index 1802922703..90d35c8bd0 100644 --- a/core/src/main/java/feign/Types.java +++ b/core/src/main/java/feign/Types.java @@ -1,5 +1,5 @@ /** - * Copyright 2012-2019 The Feign Authors + * Copyright 2012-2020 The Feign Authors * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at @@ -21,7 +21,6 @@ import java.lang.reflect.TypeVariable; import java.lang.reflect.WildcardType; import java.util.Arrays; -import java.util.Map; import java.util.NoSuchElementException; /** diff --git a/core/src/main/java/feign/Util.java b/core/src/main/java/feign/Util.java index 7a9ddfa8e5..9946919dd8 100644 --- a/core/src/main/java/feign/Util.java +++ b/core/src/main/java/feign/Util.java @@ -1,5 +1,5 @@ /** - * Copyright 2012-2019 The Feign Authors + * Copyright 2012-2020 The Feign Authors * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at @@ -37,7 +37,6 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import java.util.NoSuchElementException; import java.util.Optional; import java.util.Set; import java.util.function.Predicate; diff --git a/core/src/main/java/feign/stream/StreamDecoder.java b/core/src/main/java/feign/stream/StreamDecoder.java index 64ee79b368..5d884f4a81 100644 --- a/core/src/main/java/feign/stream/StreamDecoder.java +++ b/core/src/main/java/feign/stream/StreamDecoder.java @@ -1,5 +1,5 @@ /** - * Copyright 2012-2019 The Feign Authors + * Copyright 2012-2020 The Feign Authors * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at @@ -21,7 +21,6 @@ import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.util.Iterator; -import java.util.Spliterator; import java.util.Spliterators; import java.util.stream.Stream; import java.util.stream.StreamSupport; diff --git a/core/src/main/java/feign/template/Expression.java b/core/src/main/java/feign/template/Expression.java index f4852df8cc..12d3135d5e 100644 --- a/core/src/main/java/feign/template/Expression.java +++ b/core/src/main/java/feign/template/Expression.java @@ -1,5 +1,5 @@ /** - * Copyright 2012-2019 The Feign Authors + * Copyright 2012-2020 The Feign Authors * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at @@ -13,7 +13,6 @@ */ package feign.template; -import feign.CollectionFormat; import java.util.Optional; import java.util.regex.Pattern; diff --git a/core/src/main/java/feign/template/QueryTemplate.java b/core/src/main/java/feign/template/QueryTemplate.java index 6b596ff427..2d4ab0b191 100644 --- a/core/src/main/java/feign/template/QueryTemplate.java +++ b/core/src/main/java/feign/template/QueryTemplate.java @@ -1,5 +1,5 @@ /** - * Copyright 2012-2019 The Feign Authors + * Copyright 2012-2020 The Feign Authors * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at @@ -13,6 +13,10 @@ */ package feign.template; +import feign.CollectionFormat; +import feign.Util; +import feign.template.Template.EncodingOptions; +import feign.template.Template.ExpansionOptions; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.ArrayList; @@ -24,10 +28,6 @@ import java.util.concurrent.CopyOnWriteArrayList; import java.util.stream.Collectors; import java.util.stream.StreamSupport; -import feign.CollectionFormat; -import feign.Util; -import feign.template.Template.EncodingOptions; -import feign.template.Template.ExpansionOptions; /** * Template for a Query String parameter. @@ -49,7 +49,14 @@ public final class QueryTemplate { * @return a QueryTemplate. */ public static QueryTemplate create(String name, Iterable values, Charset charset) { - return create(name, values, charset, CollectionFormat.EXPLODED); + return create(name, values, charset, CollectionFormat.EXPLODED, true); + } + + public static QueryTemplate create(String name, + Iterable values, + Charset charset, + CollectionFormat collectionFormat) { + return create(name, values, charset, collectionFormat, true); } /** @@ -59,12 +66,14 @@ public static QueryTemplate create(String name, Iterable values, Charset * @param values in the template. * @param charset for the template. * @param collectionFormat to use. + * @param decodeSlash if slash characters should be decoded * @return a QueryTemplate */ public static QueryTemplate create(String name, Iterable values, Charset charset, - CollectionFormat collectionFormat) { + CollectionFormat collectionFormat, + boolean decodeSlash) { if (Util.isBlank(name)) { throw new IllegalArgumentException("name is required."); } @@ -78,7 +87,7 @@ public static QueryTemplate create(String name, .filter(Util::isNotBlank) .collect(Collectors.toList()); - return new QueryTemplate(name, remaining, charset, collectionFormat); + return new QueryTemplate(name, remaining, charset, collectionFormat, decodeSlash); } /** @@ -90,13 +99,14 @@ public static QueryTemplate create(String name, */ public static QueryTemplate append(QueryTemplate queryTemplate, Iterable values, - CollectionFormat collectionFormat) { + CollectionFormat collectionFormat, + boolean decodeSlash) { List queryValues = new ArrayList<>(queryTemplate.getValues()); queryValues.addAll(StreamSupport.stream(values.spliterator(), false) .filter(Util::isNotBlank) .collect(Collectors.toList())); return create(queryTemplate.getName(), queryValues, StandardCharsets.UTF_8, - collectionFormat); + collectionFormat, decodeSlash); } /** @@ -110,10 +120,11 @@ private QueryTemplate( String name, Iterable values, Charset charset, - CollectionFormat collectionFormat) { + CollectionFormat collectionFormat, + boolean decodeSlash) { this.values = new CopyOnWriteArrayList<>(); this.name = new Template(name, ExpansionOptions.ALLOW_UNRESOLVED, EncodingOptions.REQUIRED, - false, charset); + !decodeSlash, charset); this.collectionFormat = collectionFormat; /* parse each value into a template chunk for resolution later */ @@ -128,7 +139,7 @@ private QueryTemplate( value, ExpansionOptions.REQUIRED, EncodingOptions.REQUIRED, - false, + !decodeSlash, charset)); } diff --git a/core/src/main/java/feign/template/UriUtils.java b/core/src/main/java/feign/template/UriUtils.java index 379f5bffdd..a5eaa0bfdf 100644 --- a/core/src/main/java/feign/template/UriUtils.java +++ b/core/src/main/java/feign/template/UriUtils.java @@ -1,5 +1,5 @@ /** - * Copyright 2012-2019 The Feign Authors + * Copyright 2012-2020 The Feign Authors * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at @@ -15,6 +15,7 @@ import feign.Util; import java.io.ByteArrayOutputStream; +import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.nio.charset.Charset; @@ -153,16 +154,21 @@ private static String encodeChunk(String value, Charset charset, boolean allowRe } byte[] data = value.getBytes(charset); - ByteArrayOutputStream encoded = new ByteArrayOutputStream(); - for (byte b : data) { - if (isUnreserved(b) || (isReserved(b) && allowReserved)) { - encoded.write(b); - } else { - /* percent encode the byte */ - pctEncode(b, encoded); + try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) { + for (byte b : data) { + if (isUnreserved((char) b)) { + bos.write(b); + } else if (isReserved((char) b) && allowReserved) { + bos.write(b); + } else { + pctEncode(b, bos); + } } + return new String(bos.toByteArray(), charset); + } catch (IOException ioe) { + throw new IllegalStateException("Error occurred during encoding of the uri: " + + ioe.getMessage(), ioe); } - return new String(encoded.toByteArray()); } /** diff --git a/core/src/test/java/feign/RequestTemplateTest.java b/core/src/test/java/feign/RequestTemplateTest.java index 1221af53b3..1584266355 100644 --- a/core/src/test/java/feign/RequestTemplateTest.java +++ b/core/src/test/java/feign/RequestTemplateTest.java @@ -19,8 +19,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import feign.Request.HttpMethod; -import feign.template.UriUtils; import java.util.Arrays; import java.util.Collection; import java.util.Collections; @@ -476,6 +474,24 @@ public void slashShouldNotBeAppendedForMatrixParams() { .uri("/path;key1=value1;key2=value2", true); assertThat(template.url()).isEqualTo("/path;key1=value1;key2=value2"); + } + @Test + public void encodedReservedPreserveSlash() { + RequestTemplate template = new RequestTemplate(); + template.uri("/get?url={url}"); + template.method(HttpMethod.GET); + template = template.resolve(Collections.singletonMap("url", "https://www.google.com")); + assertThat(template.url()).isEqualToIgnoringCase("/get?url=https%3A//www.google.com"); + } + + @Test + public void encodedReservedEncodeSlash() { + RequestTemplate template = new RequestTemplate(); + template.uri("/get?url={url}"); + template.decodeSlash(false); + template.method(HttpMethod.GET); + template = template.resolve(Collections.singletonMap("url", "https://www.google.com")); + assertThat(template.url()).isEqualToIgnoringCase("/get?url=https%3A%2F%2Fwww.google.com"); } } diff --git a/core/src/test/java/feign/TargetTest.java b/core/src/test/java/feign/TargetTest.java index b8d990060d..9570a0c031 100644 --- a/core/src/test/java/feign/TargetTest.java +++ b/core/src/test/java/feign/TargetTest.java @@ -41,7 +41,7 @@ public void baseCaseQueryParamsArePercentEncoded() throws InterruptedException { Feign.builder().target(TestQuery.class, baseUrl).get("slash/foo", "slash/bar"); - assertThat(server.takeRequest()).hasPath("/default/slash/foo?query=slash%2Fbar"); + assertThat(server.takeRequest()).hasPath("/default/slash/foo?query=slash/bar"); } /** diff --git a/core/src/test/java/feign/assertj/RecordedRequestAssert.java b/core/src/test/java/feign/assertj/RecordedRequestAssert.java index eae1817d35..e49b61bdbe 100644 --- a/core/src/test/java/feign/assertj/RecordedRequestAssert.java +++ b/core/src/test/java/feign/assertj/RecordedRequestAssert.java @@ -1,5 +1,5 @@ /** - * Copyright 2012-2019 The Feign Authors + * Copyright 2012-2020 The Feign Authors * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at @@ -15,7 +15,6 @@ import java.util.Arrays; import java.util.Collection; -import java.util.Collections; import okhttp3.Headers; import okhttp3.mockwebserver.RecordedRequest; import org.assertj.core.api.AbstractAssert; diff --git a/core/src/test/java/feign/codec/DefaultErrorDecoderTest.java b/core/src/test/java/feign/codec/DefaultErrorDecoderTest.java index 1dca6ca9e3..1ddb42c52d 100644 --- a/core/src/test/java/feign/codec/DefaultErrorDecoderTest.java +++ b/core/src/test/java/feign/codec/DefaultErrorDecoderTest.java @@ -28,7 +28,6 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.springframework.util.StringUtils; @SuppressWarnings("deprecation") public class DefaultErrorDecoderTest { diff --git a/core/src/test/java/feign/stream/StreamDecoderTest.java b/core/src/test/java/feign/stream/StreamDecoderTest.java index 708134ce86..3332bbcb1f 100644 --- a/core/src/test/java/feign/stream/StreamDecoderTest.java +++ b/core/src/test/java/feign/stream/StreamDecoderTest.java @@ -14,7 +14,6 @@ package feign.stream; import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; import feign.Feign; import feign.Request; import feign.Request.HttpMethod; diff --git a/core/src/test/java/feign/template/QueryTemplateTest.java b/core/src/test/java/feign/template/QueryTemplateTest.java index 85131bfffa..383eaf1f1a 100644 --- a/core/src/test/java/feign/template/QueryTemplateTest.java +++ b/core/src/test/java/feign/template/QueryTemplateTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2012-2019 The Feign Authors + * Copyright 2012-2020 The Feign Authors * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at @@ -93,7 +93,7 @@ public void collectionFormat() { QueryTemplate .create("name", Arrays.asList("James", "Jason"), Util.UTF_8, CollectionFormat.CSV); String expanded = template.expand(Collections.emptyMap()); - assertThat(expanded).isEqualToIgnoringCase("name=James,Jason"); + assertThat(expanded).isEqualToIgnoringCase("name=James%2CJason"); } @Test @@ -183,7 +183,7 @@ public void expandCollectionValueWithBrackets() { String expanded = template.expand(Collections.singletonMap("collection[]", Arrays.asList("1", "2"))); /* brackets will be pct-encoded */ - assertThat(expanded).isEqualToIgnoringCase("collection%5B%5D=1,2"); + assertThat(expanded).isEqualToIgnoringCase("collection%5B%5D=1%2C2"); } @Test @@ -194,6 +194,6 @@ public void expandCollectionValueWithDollar() { String expanded = template.expand(Collections.singletonMap("$collection", Arrays.asList("1", "2"))); /* dollar will be pct-encoded */ - assertThat(expanded).isEqualToIgnoringCase("%24collection=1,2"); + assertThat(expanded).isEqualToIgnoringCase("%24collection=1%2C2"); } } diff --git a/core/src/test/java/feign/template/UriTemplateTest.java b/core/src/test/java/feign/template/UriTemplateTest.java index 9176b855db..4a1e742f5f 100644 --- a/core/src/test/java/feign/template/UriTemplateTest.java +++ b/core/src/test/java/feign/template/UriTemplateTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2012-2019 The Feign Authors + * Copyright 2012-2020 The Feign Authors * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at @@ -291,4 +291,12 @@ public void testLiteralTemplateWithQueryString() { String expanded = uriTemplate.expand(Collections.emptyMap()); assertThat(expanded).isEqualToIgnoringCase("https://api.example.com?wsdl"); } + + @Test + public void encodeReserved() { + String template = "/get?url={url}"; + UriTemplate uriTemplate = UriTemplate.create(template, Util.UTF_8); + String expanded = uriTemplate.expand(Collections.singletonMap("url", "https://www.google.com")); + assertThat(expanded).isEqualToIgnoringCase("/get?url=https%3A%2F%2Fwww.google.com"); + } } diff --git a/googlehttpclient/src/main/java/feign/googlehttpclient/GoogleHttpClient.java b/googlehttpclient/src/main/java/feign/googlehttpclient/GoogleHttpClient.java index a64c41835d..f606a9c137 100644 --- a/googlehttpclient/src/main/java/feign/googlehttpclient/GoogleHttpClient.java +++ b/googlehttpclient/src/main/java/feign/googlehttpclient/GoogleHttpClient.java @@ -29,7 +29,6 @@ import feign.Client; import feign.Request; import feign.Response; -import feign.Util; /** diff --git a/gson/src/main/java/feign/gson/GsonDecoder.java b/gson/src/main/java/feign/gson/GsonDecoder.java index f8e93bfaa8..3b7a6d6891 100644 --- a/gson/src/main/java/feign/gson/GsonDecoder.java +++ b/gson/src/main/java/feign/gson/GsonDecoder.java @@ -21,7 +21,6 @@ import java.lang.reflect.Type; import java.util.Collections; import feign.Response; -import feign.Util; import feign.codec.Decoder; import static feign.Util.UTF_8; import static feign.Util.ensureClosed; diff --git a/gson/src/test/java/feign/gson/GsonCodecTest.java b/gson/src/test/java/feign/gson/GsonCodecTest.java index e859d62a51..6e91bcf8e8 100644 --- a/gson/src/test/java/feign/gson/GsonCodecTest.java +++ b/gson/src/test/java/feign/gson/GsonCodecTest.java @@ -23,7 +23,6 @@ import org.junit.Test; import java.io.IOException; import java.util.Arrays; -import java.util.Collection; import java.util.Collections; import java.util.LinkedHashMap; import java.util.LinkedList; diff --git a/hc5/src/main/java/feign/hc5/ApacheHttp5Client.java b/hc5/src/main/java/feign/hc5/ApacheHttp5Client.java index 91052a1a8b..0929714d1c 100644 --- a/hc5/src/main/java/feign/hc5/ApacheHttp5Client.java +++ b/hc5/src/main/java/feign/hc5/ApacheHttp5Client.java @@ -32,7 +32,6 @@ import java.nio.charset.Charset; import java.util.*; import feign.*; -import feign.Request.Body; /** * This module directs Feign's http requests to Apache's diff --git a/httpclient/src/main/java/feign/httpclient/ApacheHttpClient.java b/httpclient/src/main/java/feign/httpclient/ApacheHttpClient.java index 035d6777a1..79fb866160 100644 --- a/httpclient/src/main/java/feign/httpclient/ApacheHttpClient.java +++ b/httpclient/src/main/java/feign/httpclient/ApacheHttpClient.java @@ -35,8 +35,6 @@ import java.io.InputStreamReader; import java.io.Reader; import java.nio.charset.Charset; -import java.io.UnsupportedEncodingException; -import java.net.MalformedURLException; import java.net.URI; import java.net.URISyntaxException; import java.util.ArrayList; diff --git a/httpclient/src/test/java/feign/httpclient/ApacheHttpClientTest.java b/httpclient/src/test/java/feign/httpclient/ApacheHttpClientTest.java index ef3c679247..3b0f27eacd 100644 --- a/httpclient/src/test/java/feign/httpclient/ApacheHttpClientTest.java +++ b/httpclient/src/test/java/feign/httpclient/ApacheHttpClientTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2012-2019 The Feign Authors + * Copyright 2012-2020 The Feign Authors * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at @@ -22,13 +22,11 @@ import org.apache.http.client.HttpClient; import org.apache.http.impl.client.HttpClientBuilder; import org.junit.Test; -import javax.ws.rs.GET; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.QueryParam; import java.nio.charset.StandardCharsets; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; /** * Tests client-specific behavior, such as ensuring Content-Length is sent when specified. diff --git a/jackson-jaxb/src/main/java/feign/jackson/jaxb/JacksonJaxbJsonDecoder.java b/jackson-jaxb/src/main/java/feign/jackson/jaxb/JacksonJaxbJsonDecoder.java index 045b0132f4..9fbda3e998 100644 --- a/jackson-jaxb/src/main/java/feign/jackson/jaxb/JacksonJaxbJsonDecoder.java +++ b/jackson-jaxb/src/main/java/feign/jackson/jaxb/JacksonJaxbJsonDecoder.java @@ -1,5 +1,5 @@ /** - * Copyright 2012-2019 The Feign Authors + * Copyright 2012-2020 The Feign Authors * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at @@ -19,7 +19,6 @@ import java.lang.reflect.Type; import feign.FeignException; import feign.Response; -import feign.Util; import feign.codec.Decoder; import static com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider.DEFAULT_ANNOTATIONS; import static javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE; diff --git a/jackson/src/test/java/feign/jackson/JacksonCodecTest.java b/jackson/src/test/java/feign/jackson/JacksonCodecTest.java index 7c63f930e7..2b0d4bfdd6 100644 --- a/jackson/src/test/java/feign/jackson/JacksonCodecTest.java +++ b/jackson/src/test/java/feign/jackson/JacksonCodecTest.java @@ -18,7 +18,6 @@ import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.Module; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.deser.std.StdDeserializer; import com.fasterxml.jackson.databind.module.SimpleModule; @@ -31,7 +30,6 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collection; import java.util.Collections; import java.util.Iterator; import java.util.LinkedHashMap; diff --git a/jaxrs/src/test/java/feign/jaxrs/JAXRSContractTest.java b/jaxrs/src/test/java/feign/jaxrs/JAXRSContractTest.java index b49109a1d4..c7f20f106d 100644 --- a/jaxrs/src/test/java/feign/jaxrs/JAXRSContractTest.java +++ b/jaxrs/src/test/java/feign/jaxrs/JAXRSContractTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2012-2019 The Feign Authors + * Copyright 2012-2020 The Feign Authors * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at @@ -15,7 +15,6 @@ import static feign.assertj.FeignAssertions.assertThat; import static java.util.Arrays.asList; -import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.data.MapEntry.entry; import org.junit.Rule; import org.junit.Test; diff --git a/reactive/src/main/java/feign/reactive/ReactiveFeign.java b/reactive/src/main/java/feign/reactive/ReactiveFeign.java index 96535c0fc1..d91aceefaa 100644 --- a/reactive/src/main/java/feign/reactive/ReactiveFeign.java +++ b/reactive/src/main/java/feign/reactive/ReactiveFeign.java @@ -1,5 +1,5 @@ /** - * Copyright 2012-2019 The Feign Authors + * Copyright 2012-2020 The Feign Authors * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at @@ -15,7 +15,6 @@ import feign.Contract; import feign.Feign; -import feign.InvocationHandlerFactory; abstract class ReactiveFeign { diff --git a/ribbon/src/main/java/feign/ribbon/LBClient.java b/ribbon/src/main/java/feign/ribbon/LBClient.java index c2eab418a0..d0d5063754 100644 --- a/ribbon/src/main/java/feign/ribbon/LBClient.java +++ b/ribbon/src/main/java/feign/ribbon/LBClient.java @@ -24,7 +24,6 @@ import feign.Request.HttpMethod; import java.io.IOException; import java.net.URI; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.LinkedHashMap; diff --git a/sax/src/main/java/feign/sax/SAXDecoder.java b/sax/src/main/java/feign/sax/SAXDecoder.java index 190cab839e..98193fd998 100644 --- a/sax/src/main/java/feign/sax/SAXDecoder.java +++ b/sax/src/main/java/feign/sax/SAXDecoder.java @@ -1,5 +1,5 @@ /** - * Copyright 2012-2019 The Feign Authors + * Copyright 2012-2020 The Feign Authors * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at @@ -25,7 +25,6 @@ import java.util.LinkedHashMap; import java.util.Map; import feign.Response; -import feign.Util; import feign.codec.DecodeException; import feign.codec.Decoder; import static feign.Util.checkNotNull; diff --git a/soap/src/test/java/feign/soap/SOAPCodecTest.java b/soap/src/test/java/feign/soap/SOAPCodecTest.java index b951b93c79..088e61f359 100644 --- a/soap/src/test/java/feign/soap/SOAPCodecTest.java +++ b/soap/src/test/java/feign/soap/SOAPCodecTest.java @@ -15,7 +15,6 @@ import static feign.Util.UTF_8; import static feign.assertj.FeignAssertions.assertThat; -import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; import java.lang.reflect.Type; import java.nio.charset.Charset; diff --git a/spring4/src/test/java/feign/spring/SpringContractTest.java b/spring4/src/test/java/feign/spring/SpringContractTest.java index 2252879350..2807c60166 100755 --- a/spring4/src/test/java/feign/spring/SpringContractTest.java +++ b/spring4/src/test/java/feign/spring/SpringContractTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2012-2019 The Feign Authors + * Copyright 2012-2020 The Feign Authors * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at @@ -24,7 +24,6 @@ import org.springframework.web.bind.annotation.*; import java.io.IOException; import java.util.Arrays; -import java.util.Collections; import java.util.MissingResourceException; import feign.Feign; import feign.Request;