camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <>
Subject Re: Accessing a Map header via Simple?
Date Wed, 01 Feb 2012 08:10:43 GMT
On Tue, Jan 31, 2012 at 6:12 PM, dunnlow <> wrote:
> Hi.  I have a Map<String,Object> in my header and I am trying to access it
> via Simple in my spring dsl.
> I see an example using body in the documentation and am extrapolating that
> for my header purposes.  However, I'm getting a NullPointerException, so I
> am thinking I've got bad syntax.
> My map holds key/value pairs like ->
> {("user1",""),("user2","}
> and has been added to the headers and is named uriMap.
> I want to do a lookup on "user1" for example.
> I'm trying:
>   <simple>user1=${in.header.uriMap[user1]}</simple>
> Question:
>  -  Is it ok without quotes around user1?
>  -  If there is no user1 in the map, can I use the .? to avoid a NPE like:
> in.header?.uriMap[user1]?

Ad 1)
Quotes should be preferred,  but I think there was a bug in a previous
Camel release that did not strip the quotes from the key.

Ad 2)
Yes the null safe operator should be supported by the map as well.

What Camel version are you using?

And can you post the stacktrace with the NPE ?

> Thanks!
> -J
> --
> View this message in context:
> Sent from the Camel - Users mailing list archive at

Claus Ibsen
Twitter: davsclaus, fusenews
Author of Camel in Action:

View raw message