You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2026/09/01 13:47:34 UTC

(camel) branch camel-4.22.x updated: CAMEL-24579: DataFormat.marshal graph parameter should be @Nullable

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-4.22.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-4.22.x by this push:
     new ccd2aed68511 CAMEL-24579: DataFormat.marshal graph parameter should be @Nullable
ccd2aed68511 is described below

commit ccd2aed6851104167eb46b019e51a46d71a04f80
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Sep 1 15:38:55 2026 +0200

    CAMEL-24579: DataFormat.marshal graph parameter should be @Nullable
---
 core/camel-api/src/main/java/org/apache/camel/spi/DataFormat.java | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/DataFormat.java b/core/camel-api/src/main/java/org/apache/camel/spi/DataFormat.java
index 013fa823fcc7..ebf732db125e 100644
--- a/core/camel-api/src/main/java/org/apache/camel/spi/DataFormat.java
+++ b/core/camel-api/src/main/java/org/apache/camel/spi/DataFormat.java
@@ -24,6 +24,7 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.Service;
 import org.apache.camel.util.IOHelper;
+import org.jspecify.annotations.Nullable;
 
 /**
  * Pluggable strategy for converting message bodies to and from a serialised byte-stream format, as described in the
@@ -48,11 +49,13 @@ public interface DataFormat extends Service {
      * Marshals the object to the given Stream.
      *
      * @param  exchange  the current exchange
-     * @param  graph     the object to be marshalled
+     * @param  graph     the object to be marshalled, can be <tt>null</tt> if the message body is null (for example on
+     *                   an error route) or if the implementation marshals from the exchange rather than from this
+     *                   parameter
      * @param  stream    the output stream to write the marshalled result to
      * @throws Exception can be thrown
      */
-    void marshal(Exchange exchange, Object graph, OutputStream stream) throws Exception;
+    void marshal(Exchange exchange, @Nullable Object graph, OutputStream stream) throws Exception;
 
     /**
      * Unmarshals the given stream into an object.