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

I guess there is an error in the ProviderFactory of jaxrs component.

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.2
    • Fix Version/s: 2.1.2
    • Component/s: JAX-RS
    • Labels:
      None
    • Environment:

      Windowx XP, Apache Tomcat and i used spring configuration

      Description

      I thin in the method createExceptionMapper of the org.apache.cxf.jaxrs.provider.ProviderFactory class is an error.
      The following code block is wrong i guess:

      if (exceptionType.isAssignableFrom((Class<?>)args[i])) {
      InjectionUtils.injectContextFields(em.getProvider(), em, m);
      InjectionUtils.injectContextMethods(em.getProvider(), em, m);
      return em.getProvider();
      }

      The if doesn't work correctly. I wrote a ExceptionMapper<Exception> for the general Exception class. And i tested this ExceptionMapper with a throw of a IOException and it was not called. So I decided to debug the ExceptionMapper staff and i found that the if in the code block a above is false.

      So i wrote a little test to understand this.

      System.out.println(IOException.class.isAssignableFrom(Exception.class));
      System.out.println(Exception.class.isAssignableFrom(IOException.class));

      The first line of code is what your if does and if you check this you will see it returns false. But Exception is the super class
      of IOException how could it possible. The answer is easy because the isAssignableFrom method check if the
      passed class parameter is the same or a child of the class on which isAssignableForm was called. So The bug fix will be the second line they return true.

      Please change the wrong code block the right order of parameter will be

      if (((Class<?>)args[i]).isAssignableFrom(exceptionType))

      Thank for your attention

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              pussinboost Frank Ittermann
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: