@@ -36,9 +36,10 @@ public void injectServices(ServiceRegistryImplementor serviceRegistry) {
36
36
37
37
@ Override
38
38
public <T > void put (Key <T > key , T instance ) {
39
- final io . vertx . core . Context context = Vertx . currentContext ();
39
+ final ContextInternal context = currentContext ();
40
40
if ( context != null ) {
41
41
if ( trace ) LOG .tracef ( "Putting key,value in context: [%1$s, %2$s]" , key , instance );
42
+ context .putLocal ( );
42
43
context .putLocal ( key , instance );
43
44
}
44
45
else {
@@ -47,9 +48,13 @@ public <T> void put(Key<T> key, T instance) {
47
48
}
48
49
}
49
50
51
+ private static ContextInternal currentContext () {
52
+ return (ContextInternal ) Vertx .currentContext ();
53
+ }
54
+
50
55
@ Override
51
56
public <T > T get (Key <T > key ) {
52
- final io . vertx . core . Context context = Vertx . currentContext ();
57
+ final ContextInternal context = currentContext ();
53
58
if ( context != null ) {
54
59
T local = context .getLocal ( key );
55
60
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) {
63
68
64
69
@ Override
65
70
public void remove (Key <?> key ) {
66
- final io . vertx . core . Context context = Vertx . currentContext ();
71
+ final ContextInternal context = currentContext ();
67
72
if ( context != null ) {
68
73
boolean removed = context .removeLocal ( key );
69
74
if ( trace ) LOG .tracef ( "Key %s removed from context: %s" , key , removed );
@@ -75,7 +80,7 @@ public void remove(Key<?> key) {
75
80
76
81
@ Override
77
82
public void execute (Runnable runnable ) {
78
- final io .vertx .core .Context currentContext = Vertx . currentContext ();
83
+ final io .vertx .core .Context currentContext = currentContext ();
79
84
if ( currentContext == null ) {
80
85
if ( trace ) LOG .tracef ( "Not in a Vert.x context, checking the VertxInstance service" );
81
86
final io .vertx .core .Context newContext = vertxInstance .getVertx ().getOrCreateContext ();
0 commit comments