-
Bug
-
Resolution: Unresolved
-
Normal
-
None
-
CSB-4.14.2
-
None
-
False
-
-
False
-
-
-
-
Moderate
-
Very Likely
-
0
In a jax-rs service, if I set a jakarta.ws.rs.core.Response with a null entity as the inMessage body; AND execute a log statement in the route, like:
from(CXFRS_ENDPOINT_URI).routeId("testRoute") .process(x -> { x.getIn().setBody(Response.status(Response.Status.NO_CONTENT).build()); .log("Processed request, responding with 204 No Content"); })
a NullPointerException is thrown:
Caused by: java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "is" is null at org.apache.camel.component.cxf.jaxrs.CxfConverter.toStreamCache(CxfConverter.java:132)
The issue is at the line #132 of the CxfConverter.java class:
127 @Converter(allowNull = true) 128 public static StreamCache toStreamCache(Response response, Exchange exchange) { 129 InputStream is = toInputStream(response, exchange); 130 131 TypeConverterRegistry registry = exchange.getContext().getTypeConverterRegistry(); 132 TypeConverter tc = registry.lookup(StreamCache.class, is.getClass()); 133 134 if (tc != null) { 135 return tc.convertTo(StreamCache.class, exchange, is); 136 } 137 138 return null; 139 }
since the InputStream "is" was null at line #129.