cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "david (JIRA)" <j...@apache.org>
Subject [jira] Created: (CXF-1858) JAXRSOutInterceptor throws NullPointerException for unknown requests when using exception mapper
Date Mon, 13 Oct 2008 02:22:44 GMT
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


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.


Mime
View raw message