diff --git a/core/src/main/java/feign/Feign.java b/core/src/main/java/feign/Feign.java
index 6962da64..492e384b 100644
--- a/core/src/main/java/feign/Feign.java
+++ b/core/src/main/java/feign/Feign.java
@@ -103,8 +103,8 @@ public abstract class Feign {
private Client client = new Client.Default(null, null);
private Retryer retryer = new Retryer.Default();
private Logger logger = new NoOpLogger();
- private Encoder encoder = new Encoder.Default();
- private Decoder decoder = new Decoder.Default();
+ private Encoder> encoder = new Encoder.Default();
+ private Decoder> decoder = new Decoder.Default();
private QueryMapEncoder queryMapEncoder = new FieldQueryMapEncoder();
private ErrorDecoder errorDecoder = new ErrorDecoder.Default();
private Options options = new Options();
@@ -141,12 +141,12 @@ public abstract class Feign {
return this;
}
- public Builder encoder(Encoder encoder) {
+ public Builder encoder(Encoder encoder) {
this.encoder = encoder;
return this;
}
- public Builder decoder(Decoder decoder) {
+ public Builder decoder(Decoder decoder) {
this.decoder = decoder;
return this;
}
@@ -159,8 +159,8 @@ public abstract class Feign {
/**
* Allows to map the response before passing it to the decoder.
*/
- public Builder mapAndDecode(ResponseMapper mapper, Decoder decoder) {
- this.decoder = new ResponseMappingDecoder(mapper, decoder);
+ public Builder mapAndDecode(ResponseMapper mapper, Decoder decoder) {
+ this.decoder = new ResponseMappingDecoder(mapper, decoder);
return this;
}
@@ -277,8 +277,8 @@ public abstract class Feign {
Logger logger = Capability.enrich(this.logger, capabilities);
Contract contract = Capability.enrich(this.contract, capabilities);
Options options = Capability.enrich(this.options, capabilities);
- Encoder encoder = Capability.enrich(this.encoder, capabilities);
- Decoder decoder = Capability.enrich(this.decoder, capabilities);
+ Encoder> encoder = Capability.enrich(this.encoder, capabilities);
+ Decoder> decoder = Capability.enrich(this.decoder, capabilities);
InvocationHandlerFactory invocationHandlerFactory =
Capability.enrich(this.invocationHandlerFactory, capabilities);
QueryMapEncoder queryMapEncoder = Capability.enrich(this.queryMapEncoder, capabilities);
@@ -293,18 +293,18 @@ public abstract class Feign {
}
}
- public static class ResponseMappingDecoder implements Decoder {
+ public static class ResponseMappingDecoder implements Decoder {
private final ResponseMapper mapper;
- private final Decoder delegate;
+ private final Decoder delegate;
- public ResponseMappingDecoder(ResponseMapper mapper, Decoder decoder) {
+ public ResponseMappingDecoder(ResponseMapper mapper, Decoder decoder) {
this.mapper = mapper;
this.delegate = decoder;
}
@Override
- public Object decode(Response response, Type type) throws IOException {
+ public E decode(Response response, Type type) throws IOException {
return delegate.decode(mapper.map(response, type), type);
}
}
diff --git a/core/src/main/java/feign/codec/Decoder.java b/core/src/main/java/feign/codec/Decoder.java
index 88968886..1d3129ed 100644
--- a/core/src/main/java/feign/codec/Decoder.java
+++ b/core/src/main/java/feign/codec/Decoder.java
@@ -1,5 +1,5 @@
/**
- * Copyright 2012-2020 The Feign Authors
+ * Copyright 2012-2021 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
@@ -60,7 +60,7 @@ import feign.Util;
* {@link DecodeException} unless they are a subclass of {@link FeignException} already, and unless
* the client was configured with {@link Feign.Builder#decode404()}.
*/
-public interface Decoder {
+public interface Decoder {
/**
* Decodes an http response into an object corresponding to its
@@ -75,10 +75,12 @@ public interface Decoder {
* @throws DecodeException when decoding failed due to a checked exception besides IOException.
* @throws FeignException when decoding succeeds, but conveys the operation failed.
*/
- Object decode(Response response, Type type) throws IOException, DecodeException, FeignException;
+ E decode(Response response, Type type) throws IOException, DecodeException, FeignException;
/** Default implementation of {@code Decoder}. */
- public class Default extends StringDecoder {
+ public class Default implements Decoder
*/
-public class JAXBDecoder implements Decoder {
+public class JAXBDecoder implements Decoder {
private final JAXBContextFactory jaxbContextFactory;
private final boolean namespaceAware;
diff --git a/jaxb/src/main/java/feign/jaxb/JAXBEncoder.java b/jaxb/src/main/java/feign/jaxb/JAXBEncoder.java
index 78af26d8..99e9a0f5 100644
--- a/jaxb/src/main/java/feign/jaxb/JAXBEncoder.java
+++ b/jaxb/src/main/java/feign/jaxb/JAXBEncoder.java
@@ -1,5 +1,5 @@
/**
- * Copyright 2012-2020 The Feign Authors
+ * Copyright 2012-2021 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
@@ -41,7 +41,7 @@ import feign.codec.Encoder;
* The JAXBContextFactory should be reused across requests as it caches the created JAXB contexts.
*
*/
-public class JAXBEncoder implements Encoder {
+public class JAXBEncoder implements Encoder {
private final JAXBContextFactory jaxbContextFactory;
diff --git a/json/src/main/java/feign/json/JsonDecoder.java b/json/src/main/java/feign/json/JsonDecoder.java
index 578ae3ea..b5d21468 100644
--- a/json/src/main/java/feign/json/JsonDecoder.java
+++ b/json/src/main/java/feign/json/JsonDecoder.java
@@ -49,7 +49,7 @@ import static java.lang.String.format;
* System.out.println(contributors.getJSONObject(0).getString("login"));
*
*/
-public class JsonDecoder implements Decoder {
+public class JsonDecoder implements Decoder {
@Override
public Object decode(Response response, Type type) throws IOException, DecodeException {
diff --git a/json/src/main/java/feign/json/JsonEncoder.java b/json/src/main/java/feign/json/JsonEncoder.java
index b809f196..f85e2941 100644
--- a/json/src/main/java/feign/json/JsonEncoder.java
+++ b/json/src/main/java/feign/json/JsonEncoder.java
@@ -48,7 +48,7 @@ import static java.lang.String.format;
* github.create("openfeign", "feign", contributor);
*
*/
-public class JsonEncoder implements Encoder {
+public class JsonEncoder implements Encoder {
@Override
public void encode(Object object, Type bodyType, RequestTemplate template)
diff --git a/micrometer/src/main/java/feign/micrometer/MeteredDecoder.java b/micrometer/src/main/java/feign/micrometer/MeteredDecoder.java
index c47e5baa..76edce11 100644
--- a/micrometer/src/main/java/feign/micrometer/MeteredDecoder.java
+++ b/micrometer/src/main/java/feign/micrometer/MeteredDecoder.java
@@ -25,20 +25,20 @@ import java.util.Optional;
import static feign.micrometer.MetricTagResolver.EMPTY_TAGS_ARRAY;
/**
- * Warp feign {@link Decoder} with metrics.
+ * Warp feign {@link Decoder} with metrics.
*/
-public class MeteredDecoder implements Decoder {
+public class MeteredDecoder implements Decoder {
- private final Decoder decoder;
+ private final Decoder decoder;
private final MeterRegistry meterRegistry;
private final MetricName metricName;
private final MetricTagResolver metricTagResolver;
- public MeteredDecoder(Decoder decoder, MeterRegistry meterRegistry) {
+ public MeteredDecoder(Decoder decoder, MeterRegistry meterRegistry) {
this(decoder, meterRegistry, new FeignMetricName(Decoder.class), new FeignMetricTagResolver());
}
- public MeteredDecoder(Decoder decoder, MeterRegistry meterRegistry, MetricName metricName,
+ public MeteredDecoder(Decoder decoder, MeterRegistry meterRegistry, MetricName metricName,
MetricTagResolver metricTagResolver) {
this.decoder = decoder;
this.meterRegistry = meterRegistry;
@@ -47,7 +47,7 @@ public class MeteredDecoder implements Decoder {
}
@Override
- public Object decode(Response response, Type type)
+ public E decode(Response response, Type type)
throws IOException, FeignException {
final Optional body = Optional.ofNullable(response.body())
.map(MeteredBody::new);
@@ -55,7 +55,7 @@ public class MeteredDecoder implements Decoder {
Response meteredResponse = body.map(b -> response.toBuilder().body(b).build())
.orElse(response);
- Object decoded;
+ E decoded;
final Timer.Sample sample = Timer.start(meterRegistry);
Timer timer = null;
diff --git a/micrometer/src/main/java/feign/micrometer/MeteredEncoder.java b/micrometer/src/main/java/feign/micrometer/MeteredEncoder.java
index 4437ba27..801a1426 100644
--- a/micrometer/src/main/java/feign/micrometer/MeteredEncoder.java
+++ b/micrometer/src/main/java/feign/micrometer/MeteredEncoder.java
@@ -23,18 +23,18 @@ import static feign.micrometer.MetricTagResolver.EMPTY_TAGS_ARRAY;
/**
* Warp feign {@link Encoder} with metrics.
*/
-public class MeteredEncoder implements Encoder {
+public class MeteredEncoder implements Encoder {
- private final Encoder encoder;
+ private final Encoder encoder;
private final MeterRegistry meterRegistry;
private final MetricName metricName;
private final MetricTagResolver metricTagResolver;
- public MeteredEncoder(Encoder encoder, MeterRegistry meterRegistry) {
+ public MeteredEncoder(Encoder encoder, MeterRegistry meterRegistry) {
this(encoder, meterRegistry, new FeignMetricName(Encoder.class), new FeignMetricTagResolver());
}
- public MeteredEncoder(Encoder encoder,
+ public MeteredEncoder(Encoder encoder,
MeterRegistry meterRegistry,
MetricName metricName,
MetricTagResolver metricTagResolver) {
@@ -45,7 +45,7 @@ public class MeteredEncoder implements Encoder {
}
@Override
- public void encode(Object object, Type bodyType, RequestTemplate template)
+ public void encode(E object, Type bodyType, RequestTemplate template)
throws EncodeException {
createTimer(object, bodyType, template)
.record(() -> encoder.encode(object, bodyType, template));
diff --git a/mock/src/test/java/feign/mock/MockClientSequentialTest.java b/mock/src/test/java/feign/mock/MockClientSequentialTest.java
index e3f4324e..6e44c7ba 100644
--- a/mock/src/test/java/feign/mock/MockClientSequentialTest.java
+++ b/mock/src/test/java/feign/mock/MockClientSequentialTest.java
@@ -1,5 +1,5 @@
/**
- * Copyright 2012-2020 The Feign Authors
+ * Copyright 2012-2021 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
@@ -72,16 +72,16 @@ public class MockClientSequentialTest {
}
- class AssertionDecoder implements Decoder {
+ class AssertionDecoder implements Decoder {
- private final Decoder delegate;
+ private final Decoder delegate;
- public AssertionDecoder(Decoder delegate) {
+ public AssertionDecoder(Decoder delegate) {
this.delegate = delegate;
}
@Override
- public Object decode(Response response, Type type)
+ public E decode(Response response, Type type)
throws IOException, DecodeException, FeignException {
assertThat(response.request(), notNullValue());
@@ -102,7 +102,7 @@ public class MockClientSequentialTest {
.add("Name", "netflix")
.build();
mockClientSequential = new MockClient(true);
- githubSequential = Feign.builder().decoder(new AssertionDecoder(new GsonDecoder()))
+ githubSequential = Feign.builder().decoder(new AssertionDecoder<>(new GsonDecoder()))
.client(mockClientSequential
.add(RequestKey
.builder(HttpMethod.GET, "/repos/netflix/feign/contributors")
diff --git a/mock/src/test/java/feign/mock/MockClientTest.java b/mock/src/test/java/feign/mock/MockClientTest.java
index 3ea208ee..562aa03f 100644
--- a/mock/src/test/java/feign/mock/MockClientTest.java
+++ b/mock/src/test/java/feign/mock/MockClientTest.java
@@ -68,16 +68,16 @@ public class MockClientTest {
}
- class AssertionDecoder implements Decoder {
+ class AssertionDecoder implements Decoder {
- private final Decoder delegate;
+ private final Decoder delegate;
- public AssertionDecoder(Decoder delegate) {
+ public AssertionDecoder(Decoder delegate) {
this.delegate = delegate;
}
@Override
- public Object decode(Response response, Type type)
+ public E decode(Response response, Type type)
throws IOException, DecodeException, FeignException {
assertThat(response.request(), notNullValue());
@@ -103,7 +103,7 @@ public class MockClientTest {
.body("{\"login\":\"velo_at_github\",\"type\":\"preposterous hacker\"}")
.build();
mockClient = new MockClient();
- github = Feign.builder().decoder(new AssertionDecoder(new GsonDecoder()))
+ github = Feign.builder().decoder(new AssertionDecoder<>(new GsonDecoder()))
.client(mockClient.ok(HttpMethod.GET, "/repos/netflix/feign/contributors", data)
.ok(HttpMethod.GET, "/repos/netflix/feign/contributors?client_id=55")
.ok(HttpMethod.GET, "/repos/netflix/feign/contributors?client_id=7 7",
diff --git a/sax/src/main/java/feign/sax/SAXDecoder.java b/sax/src/main/java/feign/sax/SAXDecoder.java
index 98193fd9..348c9950 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-2020 The Feign Authors
+ * Copyright 2012-2021 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
@@ -46,7 +46,7 @@ import static feign.Util.resolveLastTypeParameter;
* .target(MyApi.class, "http://api");
*
*/
-public class SAXDecoder implements Decoder {
+public class SAXDecoder implements Decoder {
private final Map> handlerFactories;
diff --git a/soap/src/main/java/feign/soap/SOAPDecoder.java b/soap/src/main/java/feign/soap/SOAPDecoder.java
index 426bd31b..abbad30a 100644
--- a/soap/src/main/java/feign/soap/SOAPDecoder.java
+++ b/soap/src/main/java/feign/soap/SOAPDecoder.java
@@ -81,7 +81,7 @@ import feign.jaxb.JAXBContextFactory;
* @see SOAPErrorDecoder
* @see SOAPFaultException
*/
-public class SOAPDecoder implements Decoder {
+public class SOAPDecoder implements Decoder {
private final JAXBContextFactory jaxbContextFactory;
diff --git a/soap/src/main/java/feign/soap/SOAPEncoder.java b/soap/src/main/java/feign/soap/SOAPEncoder.java
index 5263324b..f7096a37 100644
--- a/soap/src/main/java/feign/soap/SOAPEncoder.java
+++ b/soap/src/main/java/feign/soap/SOAPEncoder.java
@@ -83,7 +83,7 @@ import feign.jaxb.JAXBContextFactory;
* The JAXBContextFactory should be reused across requests as it caches the created JAXB contexts.
*
*/
-public class SOAPEncoder implements Encoder {
+public class SOAPEncoder implements Encoder {
private static final String DEFAULT_SOAP_PROTOCOL = SOAPConstants.SOAP_1_1_PROTOCOL;