You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Kingjamm <ki...@zoji.com> on 2008/09/05 19:16:30 UTC

Potential bug with setHeader and scripts?

So trying to figure this out, I looked into the source, and found that if the
getOut is not null, the out message is used to set the header in the
setHeader processor. Unfortunately in the script engine this block of code
always ensures that it's NOT null.

script builder class line 520 of Camel 1.4

        ScriptContext context = engine.getContext();
        int scope = ScriptContext.ENGINE_SCOPE;
        context.setAttribute("context", exchange.getContext(), scope);
        context.setAttribute("exchange", exchange, scope);
        context.setAttribute("request", exchange.getIn(), scope);
        context.setAttribute("response", exchange.getOut(), scope);

The place were the out message is used is here in the Pipeline class at line
79

            if (first) {
                first = false;
            } else {
                nextExchange = createNextExchange(processor, nextExchange);
            }

Is the correct behavior to call the getOut in the scripbuilder with an
argument of false or is there something more subtle going on here?
-- 
View this message in context: http://www.nabble.com/Potential-bug-with-setHeader-and-scripts--tp19335805s22882p19335805.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Potential bug with setHeader and scripts?

Posted by Willem Jiang <wi...@gmail.com>.
Hi,

I just committed a quick fix for the issue, and the patch also included 
a simple unit test :)
Please check out the last snapshot for verification.

Willem

Kingjamm wrote:
> I added the spring configuration to a JIRA, unfortunately I don't have time
> right now to dedicate to putting together a unit test. If you need further
> details though, please feel free to email.
>
>
>
> Claus Ibsen wrote:
>   
>> Hi
>>
>> Yeah I guess the best is to look if the exchange is out capable
>> (ExchangeHelper.isOutCapable - I think) and then only set the response
>> context.
>>
>> We would like to look and fix it. The best is to log a ticket in JIRA and
>> if possible some code showing the problem, such as a route example, unit
>> test or the like.
>>
>>
>>
>> Med venlig hilsen
>>  
>> Claus Ibsen
>> ......................................
>> Silverbullet
>> Skovsgårdsvænget 21
>> 8362 Hørning
>> Tlf. +45 2962 7576
>> Web: www.silverbullet.dk
>>
>> -----Original Message-----
>> From: Kingjamm [mailto:kingjamm@zoji.com] 
>> Sent: 5. september 2008 19:17
>> To: camel-user@activemq.apache.org
>> Subject: Potential bug with setHeader and scripts?
>>
>>
>> So trying to figure this out, I looked into the source, and found that if
>> the
>> getOut is not null, the out message is used to set the header in the
>> setHeader processor. Unfortunately in the script engine this block of code
>> always ensures that it's NOT null.
>>
>> script builder class line 520 of Camel 1.4
>>
>>         ScriptContext context = engine.getContext();
>>         int scope = ScriptContext.ENGINE_SCOPE;
>>         context.setAttribute("context", exchange.getContext(), scope);
>>         context.setAttribute("exchange", exchange, scope);
>>         context.setAttribute("request", exchange.getIn(), scope);
>>         context.setAttribute("response", exchange.getOut(), scope);
>>
>> The place were the out message is used is here in the Pipeline class at
>> line
>> 79
>>
>>             if (first) {
>>                 first = false;
>>             } else {
>>                 nextExchange = createNextExchange(processor,
>> nextExchange);
>>             }
>>
>> Is the correct behavior to call the getOut in the scripbuilder with an
>> argument of false or is there something more subtle going on here?
>> -- 
>> View this message in context:
>> http://www.nabble.com/Potential-bug-with-setHeader-and-scripts--tp19335805s22882p19335805.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
>>
>>     
>
>   


RE: Potential bug with setHeader and scripts?

Posted by Kingjamm <ki...@zoji.com>.
I added the spring configuration to a JIRA, unfortunately I don't have time
right now to dedicate to putting together a unit test. If you need further
details though, please feel free to email.



Claus Ibsen wrote:
> 
> Hi
> 
> Yeah I guess the best is to look if the exchange is out capable
> (ExchangeHelper.isOutCapable - I think) and then only set the response
> context.
> 
> We would like to look and fix it. The best is to log a ticket in JIRA and
> if possible some code showing the problem, such as a route example, unit
> test or the like.
> 
> 
> 
> Med venlig hilsen
>  
> Claus Ibsen
> ......................................
> Silverbullet
> Skovsgårdsvænget 21
> 8362 Hørning
> Tlf. +45 2962 7576
> Web: www.silverbullet.dk
> 
> -----Original Message-----
> From: Kingjamm [mailto:kingjamm@zoji.com] 
> Sent: 5. september 2008 19:17
> To: camel-user@activemq.apache.org
> Subject: Potential bug with setHeader and scripts?
> 
> 
> So trying to figure this out, I looked into the source, and found that if
> the
> getOut is not null, the out message is used to set the header in the
> setHeader processor. Unfortunately in the script engine this block of code
> always ensures that it's NOT null.
> 
> script builder class line 520 of Camel 1.4
> 
>         ScriptContext context = engine.getContext();
>         int scope = ScriptContext.ENGINE_SCOPE;
>         context.setAttribute("context", exchange.getContext(), scope);
>         context.setAttribute("exchange", exchange, scope);
>         context.setAttribute("request", exchange.getIn(), scope);
>         context.setAttribute("response", exchange.getOut(), scope);
> 
> The place were the out message is used is here in the Pipeline class at
> line
> 79
> 
>             if (first) {
>                 first = false;
>             } else {
>                 nextExchange = createNextExchange(processor,
> nextExchange);
>             }
> 
> Is the correct behavior to call the getOut in the scripbuilder with an
> argument of false or is there something more subtle going on here?
> -- 
> View this message in context:
> http://www.nabble.com/Potential-bug-with-setHeader-and-scripts--tp19335805s22882p19335805.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Potential-bug-with-setHeader-and-scripts--tp19335805s22882p19336925.html
Sent from the Camel - Users mailing list archive at Nabble.com.


RE: Potential bug with setHeader and scripts?

Posted by Claus Ibsen <ci...@silverbullet.dk>.
Hi

Yeah I guess the best is to look if the exchange is out capable (ExchangeHelper.isOutCapable - I think) and then only set the response context.

We would like to look and fix it. The best is to log a ticket in JIRA and if possible some code showing the problem, such as a route example, unit test or the like.



Med venlig hilsen
 
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk

-----Original Message-----
From: Kingjamm [mailto:kingjamm@zoji.com] 
Sent: 5. september 2008 19:17
To: camel-user@activemq.apache.org
Subject: Potential bug with setHeader and scripts?


So trying to figure this out, I looked into the source, and found that if the
getOut is not null, the out message is used to set the header in the
setHeader processor. Unfortunately in the script engine this block of code
always ensures that it's NOT null.

script builder class line 520 of Camel 1.4

        ScriptContext context = engine.getContext();
        int scope = ScriptContext.ENGINE_SCOPE;
        context.setAttribute("context", exchange.getContext(), scope);
        context.setAttribute("exchange", exchange, scope);
        context.setAttribute("request", exchange.getIn(), scope);
        context.setAttribute("response", exchange.getOut(), scope);

The place were the out message is used is here in the Pipeline class at line
79

            if (first) {
                first = false;
            } else {
                nextExchange = createNextExchange(processor, nextExchange);
            }

Is the correct behavior to call the getOut in the scripbuilder with an
argument of false or is there something more subtle going on here?
-- 
View this message in context: http://www.nabble.com/Potential-bug-with-setHeader-and-scripts--tp19335805s22882p19335805.html
Sent from the Camel - Users mailing list archive at Nabble.com.