From b3a8e58f4b1e5a0bf1d3345a342df8e7a02b7380 Mon Sep 17 00:00:00 2001 From: amaliujia Date: Wed, 5 Aug 2026 11:34:56 +0800 Subject: [PATCH] RATIS-2642. Command API in data stream can be optional --- .../java/org/apache/ratis/client/api/DataStreamOutput.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ratis-client/src/main/java/org/apache/ratis/client/api/DataStreamOutput.java b/ratis-client/src/main/java/org/apache/ratis/client/api/DataStreamOutput.java index 5e01ac7094..e32275c0ea 100644 --- a/ratis-client/src/main/java/org/apache/ratis/client/api/DataStreamOutput.java +++ b/ratis-client/src/main/java/org/apache/ratis/client/api/DataStreamOutput.java @@ -81,10 +81,15 @@ default CompletableFuture writeAsync(File src, long position, l * The server state machine may handle the command via its data-stream command hook * instead of writing bytes to the data channel. * + * This is an optional API. Implementations that do not support stream commands + * may rely on this default, which throws {@link UnsupportedOperationException}. + * * @param command the command payload * @return a future of the reply */ - CompletableFuture commandAsync(ByteBuffer command); + default CompletableFuture commandAsync(ByteBuffer command) { + throw new UnsupportedOperationException(getClass() + " does not support commandAsync"); + } /** * Return the future of the {@link RaftClientReply}