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 2009/03/05 19:03:56 UTC

[jira] Resolved: (CXF-1858) JAXRSOutInterceptor throws NullPointerException for unknown requests when using exception mapper

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

Sergey Beryozkin resolved CXF-1858.
-----------------------------------

       Resolution: Fixed
    Fix Version/s: 2.1.5
                   2.2

Fixed now

> JAXRSOutInterceptor throws NullPointerException for unknown requests when using exception mapper
> ------------------------------------------------------------------------------------------------
>
>                 Key: CXF-1858
>                 URL: https://issues.apache.org/jira/browse/CXF-1858
>             Project: CXF
>          Issue Type: Bug
>          Components: REST
>    Affects Versions: 2.1.2
>         Environment: windows XP, jdk1.6.0_07, tomcat 6.0.18
>            Reporter: david
>             Fix For: 2.2, 2.1.5
>
>
> JAX-RS webservice
> When a client requests URL that isnt a valid service endpoint and using an Exeption mapper to return more detailed error, if you add an entity in the response the JAXRSOutInterceptor throws a NPE.
> java.lang.NullPointerException
> 	at org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.processResponse(JAXRSOutInterceptor.java:150)
> 	at org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.handleMessage(JAXRSOutInterceptor.java:61)
>    .....
> The exception mapper:
> public class MyExceptionMapper implements ExceptionMapper<Exception>
> {
> 	
> 	private static Logger LOG = LogUtils.getL7dLogger(MyExceptionMapper.class);
> 	
> 	@Override
> 	public Response toResponse(Exception ex) 
> 	{
> 		LOG.logp(Level.WARNING, "MyExceptionMapper", "toResponse","Caught Exception:", ex);
> 		return Response.status(503).type("text/html").entity("Myexception error description").build();
> 	}
> }
> If I dont put the entity in the response it works, but with an entity in the response it causes a NullPointerException.
> currently in SVN and 2.1.2 JAXRSOutInterceptor.java line 150 is :
> writer.writeTo(responseObj, targetType, invoked.getGenericReturnType(), 
>                                invoked != null ? invoked.getAnnotations() : new Annotation[]{}, 
>                                responseType, 
>                                response.getMetadata(), 
>                                out);
>                 
> perhaps should be  this :
> writer.writeTo(responseObj, targetType, 
>                                invoked != null ? invoked.getGenericReturnType() : null, 
>                                invoked != null ? invoked.getAnnotations() : new Annotation[]{}, 
>                                responseType, 
>                                response.getMetadata(), 
>                                out);

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.