Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-8769

inherited static method 'fromString(String)' not considered on localTransport

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 3.5.3
    • None
    • JAX-RS, JAX-WS Runtime
    • None
    • Junit 5
      cxf local transport

    • Moderate

    Description

      Hi CXF team!

       

      Description of the error and code

      I tried to use a local transport for testing my services. However, I have a path and/or query parameter set to something like this:

      @Path("api")
      public class HelmResource {
      
        // body left out for brevity
        @PUT
        @Path("helm/{id}/files")
        public Response putFile(@PathParam("id") HelmId helmId, String entity);
      
      }
      
      // important parts of the parameter class
      
      abstract class AbstractHelmId {
      
        // watch the return type!
        public static HelmId fromString(String id) {
          return HelmId.of(new UUID(id));
        }
      }
      
      @Generated // by immutables.org
      public class HelmId {
      
        private final UUID id;
      
        // should inherit the fromString(String id) method.
      
        public static HelmId of(UUID uuid) {
          return new HelmId(uuid);
        }
      }
      

      This works perfectly fine on Open Liberty (which uses CXF), but it does not when using CXF in local test mode. I wrote a Junit5 extension based on your wiki: https://cwiki.apache.org/confluence/display/CXF20DOC/JAXRS+Testing#JAXRSTesting-LocalTransport

       

      Expected behaviour

      HelmId is being read from the path

       

      Actual behaviour

      HelmId has no constructor with single String parameter, static valueOf(String) or fromString(String) methods

       

      Workaround

      Create a ParamConverterProvider and a ParamConverter for all the classes. This eliminates the idea of the integration test though, as the test uses a provider, the production code does not.

       

      Expected solution

      The error is being thrown here: cxf/InjectionUtils.java at b6e3ab83a37cfb777d6eebf9711e552027bde37a · apache/cxf (github.com)

      I assume this method must be changed or is not properly called for local transports.

      Attachments

        Activity

          People

            Unassigned Unassigned
            bmarwell Benjamin Marwell
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: