Skip to content

Commit 742ab0b

Browse files
tsegismontDavideD
authored andcommitted
[#2174] Prepare for Vert.x 5 upgrade in Vert.x Context
Closes #2174 Local context data management methods are deprecated and will be removed in Vert.x 5. This change will make it easier to upgrade to Vert.x 5 (should be just a matter of changing imports)
1 parent 294f740 commit 742ab0b

File tree

1 file changed

+7
-6
lines changed
  • hibernate-reactive-core/src/main/java/org/hibernate/reactive/context/impl

1 file changed

+7
-6
lines changed

hibernate-reactive-core/src/main/java/org/hibernate/reactive/context/impl/VertxContext.java

+7-6
Original file line numberDiff line numberDiff line change
@@ -36,10 +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 = ContextInternal.current();
4040
if ( context != null ) {
4141
if ( trace ) LOG.tracef( "Putting key,value in context: [%1$s, %2$s]", key, instance );
42-
context.putLocal( key, instance );
42+
context.localContextData().put( key, instance );
4343
}
4444
else {
4545
if ( trace ) LOG.tracef( "Context is null for key,value: [%1$s, %2$s]", key, instance );
@@ -49,9 +49,10 @@ public <T> void put(Key<T> key, T instance) {
4949

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

6465
@Override
6566
public void remove(Key<?> key) {
66-
final io.vertx.core.Context context = Vertx.currentContext();
67+
final ContextInternal context = ContextInternal.current();
6768
if ( context != null ) {
68-
boolean removed = context.removeLocal( key );
69+
boolean removed = context.localContextData().remove( key ) != null;
6970
if ( trace ) LOG.tracef( "Key %s removed from context: %s", key, removed );
7071
}
7172
else {

0 commit comments

Comments
 (0)