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 12:42:04 UTC

[jira] [Comment Edited] (CAMEL-7589) Missing 'null' check in methods sendBodyAndHeaders() of class DefaultProducerTemplate

    [ https://issues.apache.org/jira/browse/CAMEL-7589?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14057350#comment-14057350 ] 

Concombre Masqué edited comment on CAMEL-7589 at 7/10/14 10:41 AM:
-------------------------------------------------------------------

Hi Claus,

I understand your point of view. Nevertheless the 'null' value for the headers parameter has to be properly dealt with. This is not the case in my opinion (it could be improved).


was (Author: nsaboy):
Hi Claus,

I understand your point of view. Nevertheless the 'null' value for the headers parameter has to be properly dealt with. This is not the case.

> 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.10.7, 2.13.2
>         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)