Discussion:
Passing properties from Camel to Java bean causes plus sign to be replaced with space
Pakarinen, Jari
2018-11-13 10:05:06 UTC
Permalink
Hi,

I have code that passes Java properties value that contains a + sign to Java bean (as a string). The plus sign is replaced with a space when inspected in the bean. But if I log the contents of the property inside from() ... .end() the plus sign is shown.

Example:

from("file://..")
.to("bean:ProcessExcelFile?method=processExcel('{{file.name.starts}}')
.log("{{file.name.starts}}")
.end();

In the example {{file.name.starts}} is the property that contains the plus sign. Line .log("{{file.name.starts}}") will show the plus sign in the log correctly.

But when reaching the processExcel method the plus sign has been replaced with a space. Any idea why this is happening and what could be done to prevent it ?

I tried reading a properties file with just Java code and the + sign is showing correctly.

Camel 2.22.1

King Regards,
Jari
Zoran Regvart
2018-11-13 11:01:32 UTC
Permalink
Hi Jari,
try using RAW[1], something like:

.to("bean:ProcessExcelFile?method=processExcel('RAW({{file.name.starts}}')")

zoran

[1] https://github.com/apache/camel/blob/master/docs/user-manual/en/faq/how-do-i-configure-endpoints.adoc#configuring-parameter-values-using-raw-values-eg-such-as-passwords

On Tue, Nov 13, 2018 at 11:05 AM, Pakarinen, Jari
Post by Pakarinen, Jari
Hi,
I have code that passes Java properties value that contains a + sign to Java bean (as a string). The plus sign is replaced with a space when inspected in the bean. But if I log the contents of the property inside from() ... .end() the plus sign is shown.
from("file://..")
.to("bean:ProcessExcelFile?method=processExcel('{{file.name.starts}}')
.log("{{file.name.starts}}")
.end();
In the example {{file.name.starts}} is the property that contains the plus sign. Line .log("{{file.name.starts}}") will show the plus sign in the log correctly.
But when reaching the processExcel method the plus sign has been replaced with a space. Any idea why this is happening and what could be done to prevent it ?
I tried reading a properties file with just Java code and the + sign is showing correctly.
Camel 2.22.1
King Regards,
Jari
--
Zoran Regvart
Pakarinen, Jari
2018-11-13 12:22:36 UTC
Permalink
Hi,

Thanks for the suggestion. I did not get it to work. I tried these:

RAW('{{file.name.starts}}')
RAW({{file.name.starts}})
'RAW({{file.name.starts}})'

And having the RAW() in the properties like this:

file.name.starts = RAW(my value with + sign)

In all the cases the text RAW(...) was seen in the log that was written from the Bean, as if it was just processed as text.
--
Jari


-----Original Message-----
From: Zoran Regvart [mailto:***@regvart.com]
Sent: 13. marraskuuta 2018 13:02
To: ***@camel.apache.org
Subject: Re: Passing properties from Camel to Java bean causes plus sign to be replaced with space

Hi Jari,
try using RAW[1], something like:

.to("bean:ProcessExcelFile?method=processExcel('RAW({{file.name.starts}}')")

zoran

[1] https://github.com/apache/camel/blob/master/docs/user-manual/en/faq/how-do-i-configure-endpoints.adoc#configuring-parameter-values-using-raw-values-eg-such-as-passwords
Post by Pakarinen, Jari
Hi,
I have code that passes Java properties value that contains a + sign to Java bean (as a string). The plus sign is replaced with a space when inspected in the bean. But if I log the contents of the property inside from() ... .end() the plus sign is shown.
from("file://..")
.to("bean:ProcessExcelFile?method=processExcel('{{file.name.starts}}')
.log("{{file.name.starts}}")
.end();
In the example {{file.name.starts}} is the property that contains the plus sign. Line .log("{{file.name.starts}}") will show the plus sign in the log correctly.
But when reaching the processExcel method the plus sign has been replaced with a space. Any idea why this is happening and what could be done to prevent it ?
I tried reading a properties file with just Java code and the + sign is showing correctly.
Camel 2.22.1
King Regar
Zoran Regvart
2018-11-15 08:46:15 UTC
Permalink
Hi Jarni,
yeah my mistake, sorry about that, RAW should be used for the whole
endpoint property value, try with:

.to("bean:ProcessExcelFile?method=RAW(processExcel({{file.name.starts}}))

zoran
Post by Pakarinen, Jari
Hi,
RAW('{{file.name.starts}}')
RAW({{file.name.starts}})
'RAW({{file.name.starts}})'
file.name.starts = RAW(my value with + sign)
In all the cases the text RAW(...) was seen in the log that was written from the Bean, as if it was just processed as text.
--
Jari
-----Original Message-----
Sent: 13. marraskuuta 2018 13:02
Subject: Re: Passing properties from Camel to Java bean causes plus sign to be replaced with space
Hi Jari,
.to("bean:ProcessExcelFile?method=processExcel('RAW({{file.name.starts}}')")
zoran
[1] https://github.com/apache/camel/blob/master/docs/user-manual/en/faq/how-do-i-configure-endpoints.adoc#configuring-parameter-values-using-raw-values-eg-such-as-passwords
Post by Pakarinen, Jari
Hi,
I have code that passes Java properties value that contains a + sign to Java bean (as a string). The plus sign is replaced with a space when inspected in the bean. But if I log the contents of the property inside from() ... .end() the plus sign is shown.
from("file://..")
.to("bean:ProcessExcelFile?method=processExcel('{{file.name.starts}}')
.log("{{file.name.starts}}")
.end();
In the example {{file.name.starts}} is the property that contains the plus sign. Line .log("{{file.name.starts}}") will show the plus sign in the log correctly.
But when reaching the processExcel method the plus sign has been replaced with a space. Any idea why this is happening and what could be done to prevent it ?
I tried reading a properties file with just Java code and the + sign is showing correctly.
Camel 2.22.1
King Regards,
Jari
--
Zoran Regvart
--
Zoran Regvart
Pakarinen, Jari
2018-11-19 12:48:09 UTC
Permalink
Hi,

This worked. Thank you!
--
Jari

-----Original Message-----
From: Zoran Regvart [mailto:***@regvart.com]
Sent: 15. marraskuuta 2018 10:46
To: ***@camel.apache.org
Subject: Re: Passing properties from Camel to Java bean causes plus sign to be replaced with space

Hi Jarni,
yeah my mistake, sorry about that, RAW should be used for the whole endpoint property value, try with:

.to("bean:ProcessExcelFile?method=RAW(processExcel({{file.name.starts}}))

zoran
Post by Pakarinen, Jari
Hi,
RAW('{{file.name.starts}}')
RAW({{file.name.starts}})
'RAW({{file.name.starts}})'
file.name.starts = RAW(my value with + sign)
In all the cases the text RAW(...) was seen in the log that was written from the Bean, as if it was just processed as text.
--
Jari
-----Original Message-----
Sent: 13. marraskuuta 2018 13:02
Subject: Re: Passing properties from Camel to Java bean causes plus
sign to be replaced with space
Hi Jari,
.to("bean:ProcessExcelFile?method=processExcel('RAW({{file.name.starts
}}')")
zoran
[1]
https://github.com/apache/camel/blob/master/docs/user-manual/en/faq/ho
w-do-i-configure-endpoints.adoc#configuring-parameter-values-using-raw
-values-eg-such-as-passwords
Post by Pakarinen, Jari
Hi,
I have code that passes Java properties value that contains a + sign to Java bean (as a string). The plus sign is replaced with a space when inspected in the bean. But if I log the contents of the property inside from() ... .end() the plus sign is shown.
from("file://..")
.to("bean:ProcessExcelFile?method=processExcel('{{file.name.starts}}')
.log("{{file.name.starts}}")
.end();
In the example {{file.name.starts}} is the property that contains the plus sign. Line .log("{{file.name.starts}}") will show the plus sign in the log correctly.
But when reaching the processExcel method the plus sign has been replaced with a space. Any idea why this is happening and what could be done to prevent it ?
I tried reading a properties file with just Java code and the + sign is showing correctly.
Camel 2.22.1
King Regards,
Jari
--
Zoran Regvart
Henrique Viecili
2018-11-15 22:11:28 UTC
Permalink
the '+' represents a 'space' for URI, take a look at
http://camel.465427.n5.nabble.com/URI-Escaping-in-HTTP-and-other-Producers-td4427457.html

to() interprets the String as an URI as parameter, log() doesn't

either escape the special URI characters, or replace it by %20 in the
configuration property

Regards,
Henrique Viecili
Post by Pakarinen, Jari
Hi,
RAW('{{file.name.starts}}')
RAW({{file.name.starts}})
'RAW({{file.name.starts}})'
file.name.starts = RAW(my value with + sign)
In all the cases the text RAW(...) was seen in the log that was written
from the Bean, as if it was just processed as text.
--
Jari
-----Original Message-----
Sent: 13. marraskuuta 2018 13:02
Subject: Re: Passing properties from Camel to Java bean causes plus sign
to be replaced with space
Hi Jari,
.to("bean:ProcessExcelFile?method=processExcel('RAW({{file.name.starts}}')")
zoran
[1]
https://github.com/apache/camel/blob/master/docs/user-manual/en/faq/how-do-i-configure-endpoints.adoc#configuring-parameter-values-using-raw-values-eg-such-as-passwords
Post by Pakarinen, Jari
Hi,
I have code that passes Java properties value that contains a + sign to
Java bean (as a string). The plus sign is replaced with a space when
inspected in the bean. But if I log the contents of the property inside
from() ... .end() the plus sign is shown.
Post by Pakarinen, Jari
from("file://..")
.to("bean:ProcessExcelFile?method=processExcel('{{file.name.starts}}')
Post by Pakarinen, Jari
.log("{{file.name.starts}}")
.end();
In the example {{file.name.starts}} is the property that contains the
plus sign. Line .log("{{file.name.starts}}") will show the plus sign in the
log correctly.
Post by Pakarinen, Jari
But when reaching the processExcel method the plus sign has been
replaced with a space. Any idea why this is happening and what could be
done to prevent it ?
Post by Pakarinen, Jari
I tried reading a properties file with just Java code and the + sign is
showing correctly.
Post by Pakarinen, Jari
Camel 2.22.1
King Regards,
Jari
--
Zoran Regvart
Loading...