diff --git a/http/sse/src/main/java/io/helidon/http/sse/SseEvent.java b/http/sse/src/main/java/io/helidon/http/sse/SseEvent.java index add347f4662..24a94e35f49 100644 --- a/http/sse/src/main/java/io/helidon/http/sse/SseEvent.java +++ b/http/sse/src/main/java/io/helidon/http/sse/SseEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Oracle and/or its affiliates. + * Copyright (c) 2023, 2024 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,6 +38,11 @@ */ public class SseEvent { + /** + * Value returned by {@link #data())} when no data has been set. + */ + public static final Object NO_DATA = new Object(); + private static final WritableHeaders EMPTY_HEADERS = WritableHeaders.create(); private final String id; @@ -91,7 +96,7 @@ public static Builder builder() { /** * Get data for this event. * - * @return the data + * @return the data or {@link #NO_DATA} */ public Object data() { return data; @@ -218,7 +223,7 @@ public static class Builder implements io.helidon.common.Builder event.data(Object.class)); + assertThrows(IllegalStateException.class, () -> event.data(Object.class, MediaTypes.TEXT_PLAIN)); + } }