You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (JIRA)" <ji...@apache.org> on 2014/07/10 10:38:04 UTC

[jira] [Commented] (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=14057273#comment-14057273 ] 

Claus Ibsen commented on CAMEL-7589:
------------------------------------

Why should this be allowed? If you do not have headers then use the method that do not have a header parameter.

> 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)