@@ -36,9 +36,10 @@ public void injectServices(ServiceRegistryImplementor serviceRegistry) {
3636
3737 @ Override
3838 public <T > void put (Key <T > key , T instance ) {
39- final io . vertx . core . Context context = Vertx . currentContext ();
39+ final ContextInternal context = currentContext ();
4040 if ( context != null ) {
4141 if ( trace ) LOG .tracef ( "Putting key,value in context: [%1$s, %2$s]" , key , instance );
42+ context .putLocal ( );
4243 context .putLocal ( key , instance );
4344 }
4445 else {
@@ -47,9 +48,13 @@ public <T> void put(Key<T> key, T instance) {
4748 }
4849 }
4950
51+ private static ContextInternal currentContext () {
52+ return (ContextInternal ) Vertx .currentContext ();
53+ }
54+
5055 @ Override
5156 public <T > T get (Key <T > key ) {
52- final io . vertx . core . Context context = Vertx . currentContext ();
57+ final ContextInternal context = currentContext ();
5358 if ( context != null ) {
5459 T local = context .getLocal ( key );
5560 if ( trace ) LOG .tracef ( "Getting value %2$s from context for key %1$s" , key , local );
@@ -63,7 +68,7 @@ public <T> T get(Key<T> key) {
6368
6469 @ Override
6570 public void remove (Key <?> key ) {
66- final io . vertx . core . Context context = Vertx . currentContext ();
71+ final ContextInternal context = currentContext ();
6772 if ( context != null ) {
6873 boolean removed = context .removeLocal ( key );
6974 if ( trace ) LOG .tracef ( "Key %s removed from context: %s" , key , removed );
@@ -75,7 +80,7 @@ public void remove(Key<?> key) {
7580
7681 @ Override
7782 public void execute (Runnable runnable ) {
78- final io .vertx .core .Context currentContext = Vertx . currentContext ();
83+ final io .vertx .core .Context currentContext = currentContext ();
7984 if ( currentContext == null ) {
8085 if ( trace ) LOG .tracef ( "Not in a Vert.x context, checking the VertxInstance service" );
8186 final io .vertx .core .Context newContext = vertxInstance .getVertx ().getOrCreateContext ();
0 commit comments