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

InjectionUtils createThreadLocalServletApiContext better error message for invalid @Context classes

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Trivial
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.0.6, 2.7.17, 3.1.2
    • Component/s: JAX-RS
    • Labels:
      None
    • Estimated Complexity:
      Unknown

      Description

      When you have an @Context field in a JAXRS class (maybe JAXWS too?) there is a select list of possible proxy classes. This method checks for the proxy class using an if/else/if/else... structure, but there is no final else clause with a good exception. Instead the method attempts to instantiate a null class name (proxyClassName), which throws a NullPointerException. This leaves the method wrapped inside a RuntimeException. A common forgetful change someone might make is to add

      @Context private HttpSession session; //(instead of private HttpServletRequest)

      Which leaves a massive stack trace leaving just an NPE and Spring also tends to obscure the stack-trace of this issue. A better error would be to suggest that the given class ...HttpSession is not a valid Context type. No proxy classes can be created for this type.

        Attachments

          Activity

            People

            • Assignee:
              sergey_beryozkin Sergey Beryozkin
              Reporter:
              coding Ravi Luthra
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: