Skip to content
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

Rest-Client-Reactive: void methods not allowed #22830

Closed
fwippe opened this issue Jan 12, 2022 · 1 comment · Fixed by #23472
Closed

Rest-Client-Reactive: void methods not allowed #22830

fwippe opened this issue Jan 12, 2022 · 1 comment · Fixed by #23472
Labels
area/rest-client kind/bug Something isn't working
Milestone

Comments

@fwippe
Copy link
Contributor

fwippe commented Jan 12, 2022

Describe the bug

Calling proxy endpoint methods with return type void fail with error message Response could not be mapped to type void.

Stacktrace:

javax.ws.rs.ProcessingException: Response could not be mapped to type void
	at org.jboss.resteasy.reactive.client.impl.ClientReaderInterceptorContextImpl.proceed(ClientReaderInterceptorContextImpl.java:63)
	at org.jboss.resteasy.reactive.client.impl.ClientSerialisers.invokeClientReader(ClientSerialisers.java:141)
	at org.jboss.resteasy.reactive.client.impl.RestClientRequestContext.readEntity(RestClientRequestContext.java:174)
	at org.jboss.resteasy.reactive.client.handlers.ClientResponseCompleteRestHandler.mapToResponse(ClientResponseCompleteRestHandler.java:30)
	at org.jboss.resteasy.reactive.client.handlers.ClientResponseCompleteRestHandler.handle(ClientResponseCompleteRestHandler.java:16)
	at org.jboss.resteasy.reactive.client.handlers.ClientResponseCompleteRestHandler.handle(ClientResponseCompleteRestHandler.java:12)
	at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:141)
	at org.jboss.resteasy.reactive.client.impl.RestClientRequestContext$1.lambda$execute$0(RestClientRequestContext.java:268)
	at io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:100)
	at io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:63)
	at io.vertx.core.impl.EventLoopContext.lambda$runOnContext$0(EventLoopContext.java:38)
	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:469)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.base/java.lang.Thread.run(Thread.java:834)

Work-around: Change return type to String.

Expected behavior

Successful REST call

Actual behavior

Failing REST call

How to Reproduce?

@QuarkusTest
public class RestServiceIT {
    @Inject @RestClient
    UserService userService;

    @Test
    public void mustCreateUser() {
        userService.createUser(new UserService.UserData("Max", "Max", "test@example.com"));
    }

    @RegisterRestClient(baseUri = "https://jsonplaceholder.typicode.com")
    public interface UserService {
        @Path("/users")
        @POST
        void createUser(UserData user);

        class UserData {
            @JsonProperty
            final String name;

            @JsonProperty
            final String username;

            @JsonProperty
            final String email;

            public UserData(String name, String username, String email) {
                this.name = name;
                this.username = username;
                this.email = email;
            }
        }
    }
}

Output of uname -a or ver

Microsoft Windows [Version 10.0.19042.1415]

Output of java -version

openjdk version "11.0.3" 2019-04-16 OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.3+7) OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.3+7, mixed mode)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.6.1.Final

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.8.2 (ea98e05a04480131370aa0c110b8c54cf726c06f)

Additional information

No response

@fwippe fwippe added the kind/bug Something isn't working label Jan 12, 2022
@quarkus-bot quarkus-bot bot added area/rest-client env/windows Impacts Windows machines labels Jan 12, 2022
@quarkus-bot
Copy link

quarkus-bot bot commented Jan 12, 2022

/cc @michalszynkiewicz

geoand added a commit to geoand/quarkus that referenced this issue Feb 7, 2022
@geoand geoand removed the env/windows Impacts Windows machines label Feb 7, 2022
geoand added a commit that referenced this issue Feb 7, 2022
Properly handle void return type in REST Client Reactive
@quarkus-bot quarkus-bot bot added this to the 2.8 - main milestone Feb 7, 2022
@gsmet gsmet modified the milestones: 2.8 - main, 2.7.1.Final Feb 7, 2022
gsmet pushed a commit to gsmet/quarkus that referenced this issue Feb 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/rest-client kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants