Skip to content

Commit

Permalink
Move Context methods getLocal/removeLocal/putLocal to ContextInternal…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
vietj committed Dec 18, 2024
1 parent b4433e7 commit 4a2c330
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 33 deletions.
27 changes: 0 additions & 27 deletions vertx-core/src/main/java/io/vertx/core/Context.java
Original file line number Diff line number Diff line change
Expand Up @@ -217,33 +217,6 @@ default List<String> processArgs() {
*/
boolean remove(Object key);

/**
* Get some local data from the context.
*
* @param key the key of the data
* @param <T> the type of the data
* @return the data
*/
<T> T getLocal(Object key);

/**
* Put some local data in the context.
* <p>
* 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
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,21 +364,27 @@ default <T> void removeLocal(ContextLocal<T> key, AccessMode accessMode) {
putLocal(key, accessMode, null);
}

@Deprecated
/**
* @deprecated instead use {@link #getLocal(ContextLocal, AccessMode)}
*/
@Deprecated(forRemoval = true)
@SuppressWarnings("unchecked")
@Override
default <T> 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;
}
Expand Down

0 comments on commit 4a2c330

Please sign in to comment.