You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Concombre Masqué (JIRA)" <ji...@apache.org> on 2014/07/10 10:22:08 UTC
[jira] [Created] (CAMEL-7589) Missing 'null' check in methods
sendBodyAndHeaders() of class DefaultProducerTemplate
Concombre Masqué created CAMEL-7589:
---------------------------------------
Summary: Missing 'null' check in methods sendBodyAndHeaders() of class DefaultProducerTemplate
Key: CAMEL-7589
URL: https://issues.apache.org/jira/browse/CAMEL-7589
Project: Camel
Issue Type: Bug
Components: camel-core
Affects Versions: 2.13.2, 2.10.7
Environment: Windows XP 32bits
Java 6 (update 38)
Reporter: Concombre Masqué
Priority: Minor
In class DefaultProducerTemplate, in methods :
- public void sendBodyAndHeaders(Endpoint endpoint, final Object body, final Map<String, Object> headers)
- public Object sendBodyAndHeaders(Endpoint endpoint, ExchangePattern pattern, final Object body, final Map<String, Object> headers)
Passing 'null' as last parameter (headers) should be allowed and handled correctly.
A simple check is to be added before entering the 'for' loop:
if(headers != null) {
for (Map.Entry<String, Object> header : headers.entrySet()) {
in.setHeader(header.getKey(), header.getValue());
}
}
With current implementation an exception is raised:
Caused by: java.lang.NullPointerException
at org.apache.camel.impl.DefaultProducerTemplate$2.process(DefaultProducerTemplate.java:241)
at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:346)
at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:337)
at org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:233)
at org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:337)
at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:192)
at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:115)
at org.apache.camel.impl.DefaultProducerTemplate.sendBodyAndHeaders(DefaultProducerTemplate.java:238)
--
This message was sent by Atlassian JIRA
(v6.2#6252)