camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: Camel-SJMS: Null pointer exception when sending a message (+ proposed patch)
Date Sun, 15 Mar 2015 11:40:03 GMT
Hi

Thanks for the suggestion, it has been changed.

On Sun, Mar 15, 2015 at 12:22 PM, Stanislaw Kulczycki <grung@kce.one.pl> wrote:
> Hi
>
> Many thanks for this! I have just one more bit to add, I think that in code
> of JmsMessageHelper there should be something like this:
>
>         case Message:
>             if (allowNullBody && payload == null) {
>                 answer = session.createMessage();
>             } else if(payload != null) {
>                 throw new JMSException("Unsupported message body");
>             }
>             else {
>                 throw new JMSException("Null body is not allowed");
>             }
>
> You can get to this situation:
>           else if(payload != null) {
>                 throw new JMSException("Unsupported message body");
>             }
>
> if you add test from below to JMSMessageHelperTypeConversionTest:
> @Test
>     public void testJMSMessageHelperUnknownType() throws
> InterruptedException, FileNotFoundException {
>         class TestAnonymousClass {
>             private String testValue = "Hello Camel";
>
>             public String getTestValue() {
>                 return testValue;
>             }
>         };
>         try {
>             template.sendBody(SJMS_QUEUE_URI, new TestAnonymousClass());
>         } catch (Exception e) {
>             StringWriter sw = new StringWriter();
>             PrintWriter pw = new PrintWriter(sw);
>             e.printStackTrace(pw);
>             assertFalse(sw.toString().contains("Null body is not allowed"));
> //            assertStringContains(sw.toString(), "Unsupported message body"
> );
>         }
>     }
>
> And it looks strange when you send non empty message body and get stacktrace
> like this:
>         at
> org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:137)
>         ... 30 more
> Caused by: javax.jms.JMSException: Null body is not allowed
>         at
> org.apache.camel.component.sjms.jms.JmsMessageHelper.createMessage(JmsMessageHelper.java:202)
>         at
> org.apache.camel.component.sjms.jms.JmsMessageHelper.createMessage(JmsMessageHelper.java:156)
>
> Kind regards,
> Stan
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-SJMS-Null-pointer-exception-when-sending-a-message-proposed-patch-tp5764093p5764186.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Mime
View raw message