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

find of ResponseExceptionMapper do not handle runtime exceptions

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.6.2
    • Fix Version/s: 2.6.3, 2.7
    • Component/s: JAX-RS
    • Labels:
      None
    • Estimated Complexity:
      Novice

      Description

      In org.apache.cxf.jaxrs.client.ClientProxyImpl.findExceptionMapper(Method, Message)

      The responseExceptionMapper is selected based on exception defined in the resource method signature but this method may have thrown a RuntimeException :

       
      @Path("/")
      public interface RestMcuBoardResource {
          @GET
          public RestMcuBoard getBoard();
      }
      

       

      does not work where this one work

       
      @Path("/")
      public interface RestMcuBoardResource {
          @GET
          public RestMcuBoard getBoard() throws runtimeException;
      }
      

      a fix could be :

       
          private static ResponseExceptionMapper<?> findExceptionMapper(Method m, Message message) {
              ProviderFactory pf = ProviderFactory.getInstance(message);
              for (Class<?> exType : m.getExceptionTypes()) {
                  ResponseExceptionMapper<?> mapper = pf.createResponseExceptionMapper(exType);
                  if (mapper != null) {
                      return mapper;
                  }
              }
      +        return pf.createResponseExceptionMapper(RuntimeException.class);
      -        return null; 
          }
      
      

        Attachments

          Activity

            People

            • Assignee:
              sergey_beryozkin Sergey Beryozkin
              Reporter:
              n0rad n0rad
            • Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: