Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-2885

Microprofile RestClientBuilder interface verification too restrictive

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Not a Bug
    • 3.12.1.Final, 4.6.0.Final
    • None
    • None

    Description

      Situation

      For the whole example refer to Main.java.

      I am trying to create a client for the following interface.

      @Path("/hello/{name}")
      public interface MyInterface {
      
          @Path("/")
          @GET
          String hello(@PathParam("name") String name);
      
          void foobar();
      
      }

      Note that the seconcond method does not have any JAX-RS annotations present.

      First attempt: Using RestEasy client directly

      The following statement does not throw any exception. 

      ((ResteasyWebTarget) ClientBuilder.newBuilder().build()
              .target("https://example.com"))
              .proxy(MyInterface.class);
      

      It results in a correct proxy client which can be used to access the annotated method (#hello).

      Second attempt: Using Microprofile RestClientBuilder

      The following code fails due to an error while verify the interface.

      RestClientBuilder.newBuilder()
              .baseUrl(new URL("https://example.com"))
              .build(MyInterface.class);
      

      Stacktrace:

      Exception in thread "main" org.eclipse.microprofile.rest.client.RestClientDefinitionException: Parameters and variables don't match on interface Main$MyInterface::foobar
      	at org.jboss.resteasy.microprofile.client.RestClientBuilderImpl.verifyInterface(RestClientBuilderImpl.java:551)
      	at org.jboss.resteasy.microprofile.client.RestClientBuilderImpl.build(RestClientBuilderImpl.java:218)
      	at Main.main(Main.java:22)
      

      I would expect that the second code also might generate a usable proxy.

      Cause

      The org.jboss.resteasy.microprofile.client.RestClientBuilderImpl#verifyInterface method does not distinguish between interface methods annotated with JAX-RS annotations and plain method declarations.

      Attachments

        Activity

          People

            Unassigned Unassigned
            daersc David Schury (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: