-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OpenFeign doesn't work with kotlin suspend method #1565
Comments
The alternatives I see are:
If the second alternative works, could you please contribute with an example project (like GitHub and Wikipedia examples)? If doesn't, I would be keen to help on a kotlin module. I just don't know where to get started |
I tried the second method, but I have a Controller class that inherits this interface and it doesn't work. I finally customized a class that inherits SpringMvcContract: class FeignIgnoreParameterContract(
annotatedParameterProcessors: List<AnnotatedParameterProcessor>,
conversionService: ConversionService,
decodeSlash: Boolean
) : SpringMvcContract(
annotatedParameterProcessors,
conversionService,
decodeSlash,
) {
override fun processAnnotationsOnParameter(
data: MethodMetadata,
annotations: Array<out Annotation>,
paramIndex: Int
): Boolean {
if (data.method().parameterTypes[paramIndex] == Continuation::class.java) {
data.ignoreParamater(paramIndex)
}
return super.processAnnotationsOnParameter(data, annotations, paramIndex)
}
} |
When I make a successful call to make an http request, but it fails when converting the http call result json into an object. When I remove the
|
Is that correct you want? i did using feign with coroutines using kotlin default library and do not any setting if correct that below example code, i wish i write example project "feign-with-kotlin-coroutines" |
@tmdgusya Thanks for your example. I looked at the code and my thought is https://github.com/tmdgusya/feign-with-coroutines/blob/master/src/main/kotlin/com/roach/feignwithkotlinexample/JsonPlaceHolderClients.kt#L14 method should have suspend modifier, so that TodoController can directly implement JsonPlaceHolderClients. |
@XhstormR thanks, i think that it's clients api call executed with coroutine context but I may be wrong. |
@tmdgusya I see what you mean. The problem with this issue is to make FeignClient annotated classes to resolve suspend method calls. |
@XhstormR |
@XhstormR my example code is using coroutines but not suspend function! |
Maybe, i think only one way that solving this problem that is implementation to Continuation |
That would be almost it... Could it be a non-springboot project and with a unit test for the expected behavior. ideally (not sure if that is possible or not) unit test written in java instead of kotlin. Also, would be much easier for me to pick up if was a maven project =) |
Hello guys, Are there any updates on this, please? |
Currently I have no good solution. |
Hi, I'm willing and able to help, but I have a) ZERO kotlin know-how and b) almost no free time to dedicate to learn it c) I don't have a compelling reason today If anyone really want to see this fixed I need the following:
As most I appreciate the example provided by @XhstormR , that is too far off my comfort zone |
Well, not sure if I will have enough time for this. I briefly checked the sources and to me, it doesn't look a simple task. But I don't think that in itself will give any benefits except syntactic - the calling thread is still to be blocked. |
Ok |
Resolves: OpenFeign#1565 Inspired by PlaytikaOSS/feign-reactive#486 ## TODO - [ ] Separate Kotlin support module - [ ] Enhance test case - [ ] Refactoring - [ ] Clean up pom.xml
Resolves: OpenFeign#1565 Inspired by PlaytikaOSS/feign-reactive#486 ## TODO - [ ] Separate Kotlin support module - [ ] Enhance test case - [ ] Refactoring - [ ] Clean up pom.xml
Resolves: OpenFeign#1565 Inspired by PlaytikaOSS/feign-reactive#486 ## TODO - [ ] Separate Kotlin support module - [ ] Enhance test case - [ ] Refactoring - [ ] Clean up pom.xml
Resolves: OpenFeign#1565 Inspired by PlaytikaOSS/feign-reactive#486 ## TODO - [ ] Separate Kotlin support module - [ ] Enhance test case - [ ] Refactoring - [ ] Clean up pom.xml
Resolves: OpenFeign#1565 Inspired by PlaytikaOSS/feign-reactive#486 ## TODO - [ ] Separate Kotlin support module - [ ] Enhance test case - [ ] Refactoring - [ ] Clean up pom.xml
Resolves: OpenFeign#1565 Inspired by PlaytikaOSS/feign-reactive#486 ## TODO - [ ] Separate Kotlin support module - [ ] Enhance test case - [ ] Refactoring - [ ] Clean up pom.xml
Resolves: OpenFeign#1565 Inspired by PlaytikaOSS/feign-reactive#486 ## TODO - [ ] Separate Kotlin support module - [ ] Enhance test case - [ ] Refactoring - [ ] Clean up pom.xml
Resolves: OpenFeign#1565 Inspired by PlaytikaOSS/feign-reactive#486 ## TODO - [ ] Separate Kotlin support module - [ ] Enhance test case - [ ] Refactoring - [ ] Clean up pom.xml
* Support kotlin coroutines Resolves: #1565 Inspired by PlaytikaOSS/feign-reactive#486 ## TODO - [ ] Separate Kotlin support module - [ ] Enhance test case - [ ] Refactoring - [ ] Clean up pom.xml * Apply optional dependency to kotlin support related dependency * Seperate Kotlin support module * Remove unused code from ClassUtils.java * Remove unused code from ClassUtils.java * Refactor KotlinDetector * Move ClassUtils location into KotlinDetector * Move KotlinDetector location * Format code * First attempt to move kotlin work to it's own isolated module * Coroutine Feign using AyncFeign * Coroutine Feign using AyncFeign * Refactor suspending function detect logic - Remove KotlinDetector.java - Add Method.isSuspend extension function * Cleanup CoroutineFeignTest test code format * Fix suspend function contract parsing error when using http body * Rename test names to be meaningful * Add Github Example With Coroutine - Copy of GithubExample * Remove unnecessary dependency https://github.com/OpenFeign/feign/pull/1706/files#r965389041 Co-authored-by: Marvin Froeder <velo.br@gmail.com> Co-authored-by: Marvin Froeder <velo@users.noreply.github.com>
I have an API interface where the methods are kotlin suspend methods:
But when I run the program, the program throws an exception:
This
kotlin.coroutines.Continuation
parameter is generated by the kotlin compiler at compile time, so I can't modify this parameter, how can I tell FeignClient to ignore this Continuation parameter?The text was updated successfully, but these errors were encountered: