feign icon indicating copy to clipboard operation
feign copied to clipboard

Issue running tests in gradle with feign-reactive-wrappers

Open t-patt opened this issue 2 years ago • 3 comments

I'm having an issue running unit tests with gradle while using feign-reactive-wrappers and looking for possible advice.

Simple working client example looks like:

return ReactorFeign.builder()
				.contract(new SpringContract())
				.target(MyClient.class, target);

I have a unit test that creates a client and makes a basic request. When I run the unit test via an IDE (in this case intellij) I have no problems. When I run the same unit test with gradle, I get this error:

java.lang.VerifyError: Bad return type
Exception Details:
  Location:
    feign/reactive/ReactiveFeign$Builder.contract(Lfeign/Contract;)Lfeign/BaseBuilder; @14: areturn
  Reason:
    Type 'feign/reactive/ReactiveFeign$Builder' (current frame, stack[0]) is not assignable to 'feign/BaseBuilder' (from method signature)
  Current Frame:
    bci: @14
    flags: { }
    locals: { 'feign/reactive/ReactiveFeign$Builder', 'feign/Contract', '[Z' }
    stack: { 'feign/reactive/ReactiveFeign$Builder' }
  Bytecode:
    0000000: b800 3f4d 2a2b b600 0d2c 1009 0454 b0  

	at feign.reactive.ReactorFeign.builder(ReactorFeign.java:28)

If I add the JVM option -noverify when running the test I get this error:

'feign.BaseBuilder feign.reactive.ReactiveFeign$Builder.invocationHandlerFactory(feign.InvocationHandlerFactory)'
java.lang.NoSuchMethodError: 'feign.BaseBuilder feign.reactive.ReactiveFeign$Builder.invocationHandlerFactory(feign.InvocationHandlerFactory)'
	at feign.reactive.ReactorFeign$Builder.build(ReactorFeign.java:37)
	at feign.Feign$Builder.target(Feign.java:268)
	at feign.Feign$Builder.target(Feign.java:264)

My gradle config for the tests looks like:

task myTest(type: Test) {
        testClassesDirs = files(sourceSets.myTest.java.outputDir)
        classpath += files(sourceSets.myTest.runtimeClasspath)
        useTestNG() {
                parallel = "classes"
        }
}

Any advice on how to debug the issue would be greatly appreciated. The error does not occur using the normal Feign Builder. I tried with both Java11 and Java17. Using the latest openfeign 11.9 and gradle 7.4.2.

t-patt avatar Jun 29 '22 04:06 t-patt

I faced a very similar issue when using the Resilience4jFeign.builder in one of my unit tests after updating openfeign to 11.9. The beginning of the stack trace looks like this

feign.Feign$Builder.invocationHandlerFactory(Lfeign/InvocationHandlerFactory;)Lfeign/Feign$Builder;
java.lang.NoSuchMethodError: feign.Feign$Builder.invocationHandlerFactory(Lfeign/InvocationHandlerFactory;)Lfeign/Feign$Builder;
	at io.github.resilience4j.feign.Resilience4jFeign$Builder.build(Resilience4jFeign.java:61)
	at feign.Feign$Builder.target(Feign.java:116)
	at feign.Feign$Builder.target(Feign.java:112)
       [...]

In fact this blocks the update for me. Any help on solving this issue would be appreciated

dbubenheim avatar Jun 29 '22 07:06 dbubenheim

I am experiencing the same issue when updating Feign-core from 11.8 to 11.9:

Tests work under 11.8 and fail with 11.9:

'feign.Feign$Builder feign.Feign$Builder.invocationHandlerFactory(feign.InvocationHandlerFactory)'
java.lang.NoSuchMethodError: 'feign.Feign$Builder feign.Feign$Builder.invocationHandlerFactory(feign.InvocationHandlerFactory)'
	at io.github.resilience4j.feign.Resilience4jFeign$Builder.build(Resilience4jFeign.java:61)

Seems like an incompatibility between feign-core:11.9 and resilience4j-feign:1.7.1. Using feign-core:11.9 without the Resilience4j-feign builder fixes the issue.

Issue in the resilience4j-feign is because of the Builder changes introduced in 75a3c1cf6f0e57c2d1eaa5f8be2538489e605650.

Breus avatar Jul 18 '22 11:07 Breus

I believe this incompatibility has been corrected in our latest release. Please try again with 11.9.1

kdavisk6 avatar Aug 02 '22 23:08 kdavisk6

Same error with 11.9.1 and the latest 12.1 with gradle 7.6

t-patt avatar Jan 25 '23 23:01 t-patt

A combination of gradle 8.1, reactor-core 3.5.5. and openfeign 12.3 fixed the issue for me! Closing

t-patt avatar Apr 19 '23 20:04 t-patt