From 4a2c33093650f6ac38b9e22093fa9567dc824a58 Mon Sep 17 00:00:00 2001 From: Julien Viet Date: Wed, 18 Dec 2024 08:43:33 +0100 Subject: [PATCH] Move Context methods getLocal/removeLocal/putLocal to ContextInternal and deprecate them for removal. Motivation: Context local methods should not have been part of the contract of Context initially. This API has been replaced by the ContextLocal API which should be used instead. This API is not going away in 5.0 but we want to get the opportunity to remove it at any time. --- .../src/main/java/io/vertx/core/Context.java | 27 ------------------- .../vertx/core/internal/ContextInternal.java | 18 ++++++++----- 2 files changed, 12 insertions(+), 33 deletions(-) diff --git a/vertx-core/src/main/java/io/vertx/core/Context.java b/vertx-core/src/main/java/io/vertx/core/Context.java index d906c07345d..3a507d749b1 100644 --- a/vertx-core/src/main/java/io/vertx/core/Context.java +++ b/vertx-core/src/main/java/io/vertx/core/Context.java @@ -217,33 +217,6 @@ default List processArgs() { */ boolean remove(Object key); - /** - * Get some local data from the context. - * - * @param key the key of the data - * @param the type of the data - * @return the data - */ - T getLocal(Object key); - - /** - * Put some local data in the context. - *

- * This can be used to share data between different handlers that share a context - * - * @param key the key of the data - * @param value the data - */ - void putLocal(Object key, Object value); - - /** - * Remove some local data from the context. - * - * @param key the key to remove - * @return true if removed successfully, false otherwise - */ - boolean removeLocal(Object key); - /** * @return The Vertx instance that created the context */ diff --git a/vertx-core/src/main/java/io/vertx/core/internal/ContextInternal.java b/vertx-core/src/main/java/io/vertx/core/internal/ContextInternal.java index 024ce31cf2f..7d85f97b88c 100644 --- a/vertx-core/src/main/java/io/vertx/core/internal/ContextInternal.java +++ b/vertx-core/src/main/java/io/vertx/core/internal/ContextInternal.java @@ -364,21 +364,27 @@ default void removeLocal(ContextLocal key, AccessMode accessMode) { putLocal(key, accessMode, null); } - @Deprecated + /** + * @deprecated instead use {@link #getLocal(ContextLocal, AccessMode)} + */ + @Deprecated(forRemoval = true) @SuppressWarnings("unchecked") - @Override default T getLocal(Object key) { return (T) localContextData().get(key); } - @Deprecated - @Override + /** + * @deprecated instead use {@link #putLocal(ContextLocal, AccessMode, Object)} + */ + @Deprecated(forRemoval = true) default void putLocal(Object key, Object value) { localContextData().put(key, value); } - @Deprecated - @Override + /** + * @deprecated instead use {@link #removeLocal(ContextLocal, AccessMode)} + */ + @Deprecated(forRemoval = true) default boolean removeLocal(Object key) { return localContextData().remove(key) != null; }