Skip to content

Prepare for Vert.x 5 upgrade in Vert.x Context #2175

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 2, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ public void injectServices(ServiceRegistryImplementor serviceRegistry) {

@Override
public <T> void put(Key<T> key, T instance) {
final io.vertx.core.Context context = Vertx.currentContext();
final ContextInternal context = ContextInternal.current();
if ( context != null ) {
if ( trace ) LOG.tracef( "Putting key,value in context: [%1$s, %2$s]", key, instance );
context.putLocal( key, instance );
context.localContextData().put( key, instance );
}
else {
if ( trace ) LOG.tracef( "Context is null for key,value: [%1$s, %2$s]", key, instance );
Expand All @@ -49,9 +49,10 @@ public <T> void put(Key<T> key, T instance) {

@Override
public <T> T get(Key<T> key) {
final io.vertx.core.Context context = Vertx.currentContext();
final ContextInternal context = ContextInternal.current();
if ( context != null ) {
T local = context.getLocal( key );
@SuppressWarnings("unchecked")
T local = (T) context.localContextData().get( key );
if ( trace ) LOG.tracef( "Getting value %2$s from context for key %1$s", key, local );
return local;
}
Expand All @@ -63,9 +64,9 @@ public <T> T get(Key<T> key) {

@Override
public void remove(Key<?> key) {
final io.vertx.core.Context context = Vertx.currentContext();
final ContextInternal context = ContextInternal.current();
if ( context != null ) {
boolean removed = context.removeLocal( key );
boolean removed = context.localContextData().remove( key ) != null;
if ( trace ) LOG.tracef( "Key %s removed from context: %s", key, removed );
}
else {
Expand Down
Loading