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

Jiri Ondrusek commented on CAMEL-17723:
---------------------------------------

Hi [~davsclaus], I'm debugging the code and I found a reason of the wrong 
behavior, but I'm not sure how it should be fixed.

If the route below is used
{code:java}
                from("direct:ssh")
                        .pollEnrich(
                                ssh("localhost:" + 
port).username("smx").password("smx")
                                        .useFixedDelay(true).delay(4000)
                                        .pollCommand("${header.CommandArg}"))
                        .to("mock:result");
{code}
SshEndpoint builder returns *encoded* uri 
"ssh://localhost:40249?delay=4000&password=smx&pollCommand={*}%24%7Bheader.CommandArg%7D{*}&useFixedDelay=true&username=smx"

This uri is then evaluated as an expression in `ExpressionAdapter`, but because 
it is encoded, it is not evaluated correctly.

If the workaround is used (from my first omment, which fixes test to pass), 
then url entering `ExressionAdapter` is 
`ssh://smx:smx@localhost:43915?delay=4000&password=smx&pollCommand={*}${in.header.CommandArg}{*}&useFixedDelay=true`
 ad is resolved correctly.

I have several ideas, how to solve the problem. Following 2 approaches seem to 
be "the safest ones" (shouldn't broke other code - at least I hope)
 * value can be decoded before evaluation of the expression is triggered
 * evaluation of the expression can "understand encoded strings", which will 
make evaluation to be correct

In case you have an idea how this could be solved, please let me know. (I can 
fore example turn off encodidng for dsl builders, but it may cause problems - 
from my POV)

> camel-ssh - Dynamic Header is not resolved in pollCommand
> ---------------------------------------------------------
>
>                 Key: CAMEL-17723
>                 URL: https://issues.apache.org/jira/browse/CAMEL-17723
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-ssh
>    Affects Versions: 3.15.0
>            Reporter: Guillaume N.
>            Assignee: Jiri Ondrusek
>            Priority: Minor
>         Attachments: SshComponentProducerCommandTest.java
>
>
> Hello
> I have been trying to add a dynamic argument to SSH command through a header. 
> However the pollCommand parameter does not resolve it and issue the command 
> as is.
> Please see this Zulip discussion:
> [https://camel.zulipchat.com/#narrow/stream/257298-camel/topic/Dynamic.20SSH.20command]
> I also tried to create a UnitTest to replicate the issue, please see attached.
> Best regards
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to