Comments (8)
thx @cowtowncoder. Note that this is a bit theoretical until you attach a failing test case :)
feign is only relevant for fully resolved (read not parameterized) defined java interfaces. These methods can and do have parameterized method return vals. The types used in Decoder
, for example, are captured using feign.Types
.
You'll notice that these Type
objects are properly parsed by feign-sax
(home grown) and feign-gson
. Internally at netflix, we also have a jackson module, which we can also post.
So... while things are working, I'm not sure what to do with this issue :)
from feign.
closing until this becomes an issue.
from feign.
I don't yet have a personal use case, so let me to try to explain a problem I see from API perspective.
How am I to specify that results should be, say, List of UUIDs? (List<UUID>
)?
Or parameterized response object like Response<UserOperation<Addition>>
?
I am looking at this from module implementor's perspective, but same issue exist from user perspective: you can pass a Class<?>
, but those are type-erased.
Alternative you can of course say that Feign only supports binding to/from non-generic POJOs. If so, that is an acceptable limitation (to me), and makes it clear that generics are not supported for root values.
from feign.
It isn't expected or supported for someone to use Decoder
outside of feign. When Feign calls Decoder.decode(Response, Type)
, a proper type is passed as an argument or else decoders like our gson one would never work. If you look at denominator, or the test cases, you'll notice parameterized types are used, for example. This is why I'm saying this is theoretical until the issue raises a valid limitation.
The decoder's responsibility is to use this type object to, for example, construct its own type token as necessary. If the implementation cannot do that, then that's a limitation of the implementation. When I used jackson, I had to use the type token factory thing to create one from the type passed to Decoder. If you still have trouble, I can dig that up.
from feign.
Easiest way to complete this task w/o getting into abstract type discussion is to copy paste this and revise it slightly to match feign interface def
from feign.
p.s. if you are interested in how the type passed to decoder.decode is constructed, here's the sequence.
Some subtype of feign.Contract
processes the method defined on the interface being processed.
This sets MethodMetadata.returnType(method.getGenericReturnType())
This metadata is held constant for all invocations of the decoder.
If someone wanted to unit test the decoder behavior, they'd want to either save a generic type off using TypeToken, or make a static inner interface in the test class and pull method.getGenericReturnType()
, or something more fancy :)
HTH
from feign.
hopefully this helps..
from feign.
Ok thank you. This does make more sense, wrt. what users can pass. The problem is then more limited, and I agree it is not of immediate concern. So this can be reopened if it becomes an actual problem.
I still think that use of Type
often leads to problems (the reason I submitted this was because it is common problem case for Jersey, FWIW), but it is true that problem is contextual: passing Type
from method return value or Field
is always problematic, if type has type variables that are bound by class; whereas passing Type
that is parameterization of a "type token" is not (since it defines type at class level where all information is indeed available).
Thank you for taking time to check this out and explain flow of type information through Feign.
from feign.
Related Issues (20)
- Noop Hostname Verifier option does not appear to work with Java 21
- Bug:ConcurrentModificationException at feign.SynchronousMethodHandler.targetRequest(SynchronousMethodHandler.java:162)
- Error in RequestTemplate#uri when there're both query and fragment
- Error in Expressions.PathStyleExpression#getValue
- @GetMapping Required String parameter is not present HOT 3
- JacksonJrDecoder is not able to deserialize generics
- feign.jackson.jr.JacksonJrDecoder#findTransformer is not extendable
- [Feature Request] Support custom tags for Dropwizard metrics
- Unexpected FeignException instead of ResponseEntity when the server returns 401 HOT 1
- Response.protocolVersoin may be null causing NPEs
- feign-micrometer: spanId/parentId information lost HOT 2
- Breaking change with Alpha version of OkHttp3 Library HOT 2
- Headers annotation not sending headers HOT 2
- Feign changes capitalization of header-keys HOT 1
- feign-micrometer: No client tag on MicrometerObservation meters
- Add documentation/exception for required java compiler flag "parameters"
- Even using OptionalDecoder I get an exception on 404 HOT 1
- Builder breaks resilience4j 1.7.x (latest java <17 compatible release) HOT 3
- Call Timeout(OKHTTP) not working for my Open Feign Config. HOT 17
- @PatchMapping and @DeleteMapping insert unwanted slash when using url and specific value HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from feign.