You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by Charles Moulliard <cm...@gmail.com> on 2009/06/16 11:50:56 UTC

Error not raised by Camel if the @Header type define in a bean is not correct

Hi,

Is it an issue or not ?

If I define the parameters of my bean method like this :

    public RequestMessage saveRequestMessage(
        @Body RequestMessage requestMessage,
        @Header(value = "messageType") String messageType,
        @Header(value = "requestId") String requestId,
        @Header(value = "validationResult") List<Audit> errors)

Camel does not raise an error if the content of the header validationResult
does not correspond to the type List<Audit> ?

Regards,

Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer

*****************************
blog : http://cmoulliard.blogspot.com

Re: Error not raised by Camel if the @Header type define in a bean is not correct

Posted by Claus Ibsen <cl...@gmail.com>.
See ticket
https://issues.apache.org/activemq/browse/CAMEL-1719

-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Error not raised by Camel if the @Header type define in a bean is not correct

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Jun 16, 2009 at 1:27 PM, Charles Moulliard<cm...@gmail.com> wrote:
> Probably that trying to convert a HashMap into a String was not a good
> example
>
> So I have modified the method signature like this :
>
>        public void myMethod(@Header(value = "users") ArrayList users,
> Object body) {
>
I have looked into it. The issue is that Camel cannot convert to the
desired type and the value for the parameter is evaluated to null.
I have fixed this so you get a type converter exception in this case.

The String type however is not possible to fix at this moment.



>
> and the test does not fail !!!!!
>
>
> Charles Moulliard
> Senior Enterprise Architect
> Apache Camel Committer
>
> *****************************
> blog : http://cmoulliard.blogspot.com
>
>
> On Tue, Jun 16, 2009 at 1:19 PM, Claus Ibsen <cl...@gmail.com> wrote:
>
>> On Tue, Jun 16, 2009 at 12:53 PM, Charles Moulliard<cm...@gmail.com>
>> wrote:
>> > I have created a test case. I will send you this afternoon through irc
>> > channel
>> The problem is that if you use String as type then Camel will be able
>> to use a fallback converter that is invoke the toString() on the
>> object.
>> And they often just return a log string about the object instance
>> (something like MyUser@34fr33) and that is not desireable. But sadly
>> Java has this flaw of not having a special method for DEBUG logs of
>> object instances.
>>
>>
>>
>> >
>> > Regards,
>> >
>> > Charles Moulliard
>> > Senior Enterprise Architect
>> > Apache Camel Committer
>> >
>> > *****************************
>> > blog : http://cmoulliard.blogspot.com
>> >
>> >
>> > On Tue, Jun 16, 2009 at 12:09 PM, Claus Ibsen <cl...@gmail.com>
>> wrote:
>> >
>> >> On Tue, Jun 16, 2009 at 11:50 AM, Charles Moulliard<
>> cmoulliard@gmail.com>
>> >> wrote:
>> >> > Hi,
>> >> >
>> >> > Is it an issue or not ?
>> >> >
>> >> > If I define the parameters of my bean method like this :
>> >> >
>> >> >    public RequestMessage saveRequestMessage(
>> >> >        @Body RequestMessage requestMessage,
>> >> >        @Header(value = "messageType") String messageType,
>> >> >        @Header(value = "requestId") String requestId,
>> >> >        @Header(value = "validationResult") List<Audit> errors)
>> >> >
>> >> > Camel does not raise an error if the content of the header
>> >> validationResult
>> >> > does not correspond to the type List<Audit> ?
>> >>
>> >> Camel will do a type convertions using the camel type converter.
>> >> And I guess it uses a silent type converter so in case it cannot
>> >> convert it it get a null value.
>> >>
>> >> Can you create a small unit test that demonstrates this issue? To be
>> >> used so I can look into letting Camel
>> >> fail with an type conversion error.
>> >>
>> >>
>> >> >
>> >> > Regards,
>> >> >
>> >> > Charles Moulliard
>> >> > Senior Enterprise Architect
>> >> > Apache Camel Committer
>> >> >
>> >> > *****************************
>> >> > blog : http://cmoulliard.blogspot.com
>> >> >
>> >>
>> >>
>> >>
>> >> --
>> >> Claus Ibsen
>> >> Apache Camel Committer
>> >>
>> >> Open Source Integration: http://fusesource.com
>> >> Blog: http://davsclaus.blogspot.com/
>> >> Twitter: http://twitter.com/davsclaus
>> >>
>> >
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Error not raised by Camel if the @Header type define in a bean is not correct

Posted by Charles Moulliard <cm...@gmail.com>.
Probably that trying to convert a HashMap into a String was not a good
example

So I have modified the method signature like this :

        public void myMethod(@Header(value = "users") ArrayList users,
Object body) {

and the test does not fail !!!!!


Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer

*****************************
blog : http://cmoulliard.blogspot.com


On Tue, Jun 16, 2009 at 1:19 PM, Claus Ibsen <cl...@gmail.com> wrote:

> On Tue, Jun 16, 2009 at 12:53 PM, Charles Moulliard<cm...@gmail.com>
> wrote:
> > I have created a test case. I will send you this afternoon through irc
> > channel
> The problem is that if you use String as type then Camel will be able
> to use a fallback converter that is invoke the toString() on the
> object.
> And they often just return a log string about the object instance
> (something like MyUser@34fr33) and that is not desireable. But sadly
> Java has this flaw of not having a special method for DEBUG logs of
> object instances.
>
>
>
> >
> > Regards,
> >
> > Charles Moulliard
> > Senior Enterprise Architect
> > Apache Camel Committer
> >
> > *****************************
> > blog : http://cmoulliard.blogspot.com
> >
> >
> > On Tue, Jun 16, 2009 at 12:09 PM, Claus Ibsen <cl...@gmail.com>
> wrote:
> >
> >> On Tue, Jun 16, 2009 at 11:50 AM, Charles Moulliard<
> cmoulliard@gmail.com>
> >> wrote:
> >> > Hi,
> >> >
> >> > Is it an issue or not ?
> >> >
> >> > If I define the parameters of my bean method like this :
> >> >
> >> >    public RequestMessage saveRequestMessage(
> >> >        @Body RequestMessage requestMessage,
> >> >        @Header(value = "messageType") String messageType,
> >> >        @Header(value = "requestId") String requestId,
> >> >        @Header(value = "validationResult") List<Audit> errors)
> >> >
> >> > Camel does not raise an error if the content of the header
> >> validationResult
> >> > does not correspond to the type List<Audit> ?
> >>
> >> Camel will do a type convertions using the camel type converter.
> >> And I guess it uses a silent type converter so in case it cannot
> >> convert it it get a null value.
> >>
> >> Can you create a small unit test that demonstrates this issue? To be
> >> used so I can look into letting Camel
> >> fail with an type conversion error.
> >>
> >>
> >> >
> >> > Regards,
> >> >
> >> > Charles Moulliard
> >> > Senior Enterprise Architect
> >> > Apache Camel Committer
> >> >
> >> > *****************************
> >> > blog : http://cmoulliard.blogspot.com
> >> >
> >>
> >>
> >>
> >> --
> >> Claus Ibsen
> >> Apache Camel Committer
> >>
> >> Open Source Integration: http://fusesource.com
> >> Blog: http://davsclaus.blogspot.com/
> >> Twitter: http://twitter.com/davsclaus
> >>
> >
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>

Re: Error not raised by Camel if the @Header type define in a bean is not correct

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Jun 16, 2009 at 12:53 PM, Charles Moulliard<cm...@gmail.com> wrote:
> I have created a test case. I will send you this afternoon through irc
> channel
The problem is that if you use String as type then Camel will be able
to use a fallback converter that is invoke the toString() on the
object.
And they often just return a log string about the object instance
(something like MyUser@34fr33) and that is not desireable. But sadly
Java has this flaw of not having a special method for DEBUG logs of
object instances.



>
> Regards,
>
> Charles Moulliard
> Senior Enterprise Architect
> Apache Camel Committer
>
> *****************************
> blog : http://cmoulliard.blogspot.com
>
>
> On Tue, Jun 16, 2009 at 12:09 PM, Claus Ibsen <cl...@gmail.com> wrote:
>
>> On Tue, Jun 16, 2009 at 11:50 AM, Charles Moulliard<cm...@gmail.com>
>> wrote:
>> > Hi,
>> >
>> > Is it an issue or not ?
>> >
>> > If I define the parameters of my bean method like this :
>> >
>> >    public RequestMessage saveRequestMessage(
>> >        @Body RequestMessage requestMessage,
>> >        @Header(value = "messageType") String messageType,
>> >        @Header(value = "requestId") String requestId,
>> >        @Header(value = "validationResult") List<Audit> errors)
>> >
>> > Camel does not raise an error if the content of the header
>> validationResult
>> > does not correspond to the type List<Audit> ?
>>
>> Camel will do a type convertions using the camel type converter.
>> And I guess it uses a silent type converter so in case it cannot
>> convert it it get a null value.
>>
>> Can you create a small unit test that demonstrates this issue? To be
>> used so I can look into letting Camel
>> fail with an type conversion error.
>>
>>
>> >
>> > Regards,
>> >
>> > Charles Moulliard
>> > Senior Enterprise Architect
>> > Apache Camel Committer
>> >
>> > *****************************
>> > blog : http://cmoulliard.blogspot.com
>> >
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Error not raised by Camel if the @Header type define in a bean is not correct

Posted by Charles Moulliard <cm...@gmail.com>.
I have created a test case. I will send you this afternoon through irc
channel

Regards,

Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer

*****************************
blog : http://cmoulliard.blogspot.com


On Tue, Jun 16, 2009 at 12:09 PM, Claus Ibsen <cl...@gmail.com> wrote:

> On Tue, Jun 16, 2009 at 11:50 AM, Charles Moulliard<cm...@gmail.com>
> wrote:
> > Hi,
> >
> > Is it an issue or not ?
> >
> > If I define the parameters of my bean method like this :
> >
> >    public RequestMessage saveRequestMessage(
> >        @Body RequestMessage requestMessage,
> >        @Header(value = "messageType") String messageType,
> >        @Header(value = "requestId") String requestId,
> >        @Header(value = "validationResult") List<Audit> errors)
> >
> > Camel does not raise an error if the content of the header
> validationResult
> > does not correspond to the type List<Audit> ?
>
> Camel will do a type convertions using the camel type converter.
> And I guess it uses a silent type converter so in case it cannot
> convert it it get a null value.
>
> Can you create a small unit test that demonstrates this issue? To be
> used so I can look into letting Camel
> fail with an type conversion error.
>
>
> >
> > Regards,
> >
> > Charles Moulliard
> > Senior Enterprise Architect
> > Apache Camel Committer
> >
> > *****************************
> > blog : http://cmoulliard.blogspot.com
> >
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>

Re: Error not raised by Camel if the @Header type define in a bean is not correct

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Jun 16, 2009 at 11:50 AM, Charles Moulliard<cm...@gmail.com> wrote:
> Hi,
>
> Is it an issue or not ?
>
> If I define the parameters of my bean method like this :
>
>    public RequestMessage saveRequestMessage(
>        @Body RequestMessage requestMessage,
>        @Header(value = "messageType") String messageType,
>        @Header(value = "requestId") String requestId,
>        @Header(value = "validationResult") List<Audit> errors)
>
> Camel does not raise an error if the content of the header validationResult
> does not correspond to the type List<Audit> ?

Camel will do a type convertions using the camel type converter.
And I guess it uses a silent type converter so in case it cannot
convert it it get a null value.

Can you create a small unit test that demonstrates this issue? To be
used so I can look into letting Camel
fail with an type conversion error.


>
> Regards,
>
> Charles Moulliard
> Senior Enterprise Architect
> Apache Camel Committer
>
> *****************************
> blog : http://cmoulliard.blogspot.com
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus