Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-11948

NPE on DefaultMessage setBody if deprecated constructor was used

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.20.0
    • 2.20.1, 2.21.0
    • camel-core
    • None
    • Moderate

    Description

      After upgrade camel 2.20.0, some operations fail with a NullPointerException:

      Caused by: java.lang.NullPointerException
              at org.apache.camel.impl.MessageSupport.setBody(MessageSupport.java:122)
      

      The issue seems to be introduced with the change CAMEL-11380.

      The issue could be easily reproduced by using the deprecated constructor, where no camelContext is set:

              Message message = new DefaultMessage();
              message.setBody("something");
      

      To remain better backward compatibility, i would suggest a nullcheck in the setBody for cases where the CamelContext is not set.

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            davsclaus Claus Ibsen
            thopap Thomas Papke
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment