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

NPE on DefaultMessage setBody if deprecated constructor was used

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.20.0
    • Fix Version/s: 2.20.1, 2.21.0
    • Component/s: camel-core
    • Labels:
      None
    • Estimated Complexity:
      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

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: