You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Sergey Beryozkin (JIRA)" <ji...@apache.org> on 2015/06/30 23:33:04 UTC

[jira] [Resolved] (CXF-6480) InjectionUtils createThreadLocalServletApiContext better error message for invalid @Context classes

     [ https://issues.apache.org/jira/browse/CXF-6480?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sergey Beryozkin resolved CXF-6480.
-----------------------------------
       Resolution: Fixed
    Fix Version/s: 3.1.2
                   2.7.17
                   3.0.6

I've update the code to avoid NPE. Note if it is a not well-known context then CXF will create a proxy for it anyway and a custom ContextProvider can be registered, example, ContextProvider<HttpSession>. we have a different issue where the question is whether it should be null by default  as opposed to a proxy, but that is a different issue  

> InjectionUtils createThreadLocalServletApiContext better error message for invalid @Context classes
> ---------------------------------------------------------------------------------------------------
>
>                 Key: CXF-6480
>                 URL: https://issues.apache.org/jira/browse/CXF-6480
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>            Reporter: Ravi Luthra
>            Assignee: Sergey Beryozkin
>            Priority: Trivial
>             Fix For: 3.0.6, 2.7.17, 3.1.2
>
>
> 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
> {code}@Context private HttpSession session; //(instead of private HttpServletRequest){code}
> 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.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)