From 7fc8a7a93a52be4172d862c90322b5d2d2e3c0cd Mon Sep 17 00:00:00 2001 From: Julien Viet Date: Sun, 17 Nov 2019 11:34:14 +0100 Subject: [PATCH] Annotate EventBus body parameters with Nullable - see #3199 --- .../java/io/vertx/core/eventbus/EventBus.java | 17 +++++++++-------- .../java/io/vertx/core/eventbus/Message.java | 12 ++++++------ 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/main/java/io/vertx/core/eventbus/EventBus.java b/src/main/java/io/vertx/core/eventbus/EventBus.java index e00f1afa7..6f595af47 100644 --- a/src/main/java/io/vertx/core/eventbus/EventBus.java +++ b/src/main/java/io/vertx/core/eventbus/EventBus.java @@ -13,6 +13,7 @@ package io.vertx.core.eventbus; import io.vertx.codegen.annotations.Fluent; import io.vertx.codegen.annotations.GenIgnore; +import io.vertx.codegen.annotations.Nullable; import io.vertx.codegen.annotations.VertxGen; import io.vertx.core.AsyncResult; import io.vertx.core.Future; @@ -44,7 +45,7 @@ public interface EventBus extends Measured { * @return a reference to this, so the API can be used fluently */ @Fluent - EventBus send(String address, Object message); + EventBus send(String address, @Nullable Object message); /** * Like {@link #send(String, Object)} but specifying {@code options} that can be used to configure the delivery. @@ -55,7 +56,7 @@ public interface EventBus extends Measured { * @return a reference to this, so the API can be used fluently */ @Fluent - EventBus send(String address, Object message, DeliveryOptions options); + EventBus send(String address, @Nullable Object message, DeliveryOptions options); /** * Sends a message and and specify a {@code replyHandler} that will be called if the recipient @@ -69,14 +70,14 @@ public interface EventBus extends Measured { * @return a reference to this, so the API can be used fluently */ @Fluent - default EventBus request(String address, Object message, Handler>> replyHandler) { + default EventBus request(String address, @Nullable Object message, Handler>> replyHandler) { return request(address, message, new DeliveryOptions(), replyHandler); } /** * Like {@link #request(String, Object, Handler)} but returns a {@code Future} of the asynchronous result */ - default Future> request(String address, Object message) { + default Future> request(String address, @Nullable Object message) { return request(address, message, new DeliveryOptions()); } @@ -90,7 +91,7 @@ public interface EventBus extends Measured { * @return a reference to this, so the API can be used fluently */ @Fluent - default EventBus request(String address, Object message, DeliveryOptions options, Handler>> replyHandler) { + default EventBus request(String address, @Nullable Object message, DeliveryOptions options, Handler>> replyHandler) { Future> reply = request(address, message, options); reply.setHandler(replyHandler); return this; @@ -99,7 +100,7 @@ public interface EventBus extends Measured { /** * Like {@link #request(String, Object, DeliveryOptions, Handler)} but returns a {@code Future} of the asynchronous result */ - Future> request(String address, Object message, DeliveryOptions options); + Future> request(String address, @Nullable Object message, DeliveryOptions options); /** * Publish a message.

@@ -111,7 +112,7 @@ public interface EventBus extends Measured { * */ @Fluent - EventBus publish(String address, Object message); + EventBus publish(String address, @Nullable Object message); /** * Like {@link #publish(String, Object)} but specifying {@code options} that can be used to configure the delivery. @@ -122,7 +123,7 @@ public interface EventBus extends Measured { * @return a reference to this, so the API can be used fluently */ @Fluent - EventBus publish(String address, Object message, DeliveryOptions options); + EventBus publish(String address, @Nullable Object message, DeliveryOptions options); /** * Create a message consumer against the specified address. diff --git a/src/main/java/io/vertx/core/eventbus/Message.java b/src/main/java/io/vertx/core/eventbus/Message.java index 0a9749098..8d6890075 100644 --- a/src/main/java/io/vertx/core/eventbus/Message.java +++ b/src/main/java/io/vertx/core/eventbus/Message.java @@ -77,7 +77,7 @@ public interface Message { * * @param message the message to reply with. */ - default void reply(Object message) { + default void reply(@Nullable Object message) { reply(message, new DeliveryOptions()); } @@ -87,7 +87,7 @@ public interface Message { * @param message the reply message * @param options the delivery options */ - void reply(Object message, DeliveryOptions options); + void reply(@Nullable Object message, DeliveryOptions options); /** * Reply to this message, specifying a {@code replyHandler} for the reply - i.e. @@ -100,14 +100,14 @@ public interface Message { * @param message the message to reply with. * @param replyHandler the reply handler for the reply. */ - default void replyAndRequest(Object message, Handler>> replyHandler) { + default void replyAndRequest(@Nullable Object message, Handler>> replyHandler) { replyAndRequest(message, new DeliveryOptions(), replyHandler); } /** * Like {@link #replyAndRequest(Object, Handler)} but returns a {@code Future} of the asynchronous result */ - default Future> replyAndRequest(Object message) { + default Future> replyAndRequest(@Nullable Object message) { return replyAndRequest(message, new DeliveryOptions()); } @@ -119,14 +119,14 @@ public interface Message { * @param options delivery options * @param replyHandler reply handler will be called when any reply from the recipient is received */ - default void replyAndRequest(Object message, DeliveryOptions options, Handler>> replyHandler) { + default void replyAndRequest(@Nullable Object message, DeliveryOptions options, Handler>> replyHandler) { this.replyAndRequest(message, options).setHandler(replyHandler); } /** * Like {@link #replyAndRequest(Object, DeliveryOptions, Handler)} but returns a {@code Future} of the asynchronous result */ - Future> replyAndRequest(Object message, DeliveryOptions options); + Future> replyAndRequest(@Nullable Object message, DeliveryOptions options); /** * Signal to the sender that processing of this message failed.