Adapt to API changes in the latest reactor snapshot
This commit is contained in:
@@ -887,8 +887,8 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init
|
||||
// target invocation exception
|
||||
return completeTransactionAfterThrowing(it, ex).then(Mono.error(ex));
|
||||
}
|
||||
})).subscriberContext(TransactionContextManager.getOrCreateContext())
|
||||
.subscriberContext(TransactionContextManager.getOrCreateContextHolder());
|
||||
})).contextWrite(TransactionContextManager.getOrCreateContext())
|
||||
.contextWrite(TransactionContextManager.getOrCreateContextHolder());
|
||||
}
|
||||
|
||||
// Any other reactive type, typically a Flux
|
||||
@@ -917,8 +917,8 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init
|
||||
// target invocation exception
|
||||
return completeTransactionAfterThrowing(it, ex).then(Mono.error(ex));
|
||||
}
|
||||
})).subscriberContext(TransactionContextManager.getOrCreateContext())
|
||||
.subscriberContext(TransactionContextManager.getOrCreateContextHolder()));
|
||||
})).contextWrite(TransactionContextManager.getOrCreateContext())
|
||||
.contextWrite(TransactionContextManager.getOrCreateContextHolder()));
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
|
||||
@@ -50,19 +50,17 @@ public abstract class TransactionContextManager {
|
||||
* or no context found in a holder
|
||||
*/
|
||||
public static Mono<TransactionContext> currentContext() throws NoTransactionException {
|
||||
return Mono.subscriberContext().handle((ctx, sink) -> {
|
||||
return Mono.deferContextual(ctx -> {
|
||||
if (ctx.hasKey(TransactionContext.class)) {
|
||||
sink.next(ctx.get(TransactionContext.class));
|
||||
return;
|
||||
return Mono.just(ctx.get(TransactionContext.class));
|
||||
}
|
||||
if (ctx.hasKey(TransactionContextHolder.class)) {
|
||||
TransactionContextHolder holder = ctx.get(TransactionContextHolder.class);
|
||||
if (holder.hasContext()) {
|
||||
sink.next(holder.currentContext());
|
||||
return;
|
||||
return Mono.just(holder.currentContext());
|
||||
}
|
||||
}
|
||||
sink.error(new NoTransactionInContextException());
|
||||
return Mono.error(new NoTransactionInContextException());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -82,8 +82,8 @@ final class TransactionalOperatorImpl implements TransactionalOperator {
|
||||
this.transactionManager::commit, (res, err) -> Mono.empty(), this.transactionManager::rollback)
|
||||
.onErrorResume(ex -> rollbackOnException(it, ex).then(Mono.error(ex))));
|
||||
})
|
||||
.subscriberContext(TransactionContextManager.getOrCreateContext())
|
||||
.subscriberContext(TransactionContextManager.getOrCreateContextHolder());
|
||||
.contextWrite(TransactionContextManager.getOrCreateContext())
|
||||
.contextWrite(TransactionContextManager.getOrCreateContextHolder());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -104,8 +104,8 @@ final class TransactionalOperatorImpl implements TransactionalOperator {
|
||||
.onErrorResume(ex ->
|
||||
rollbackOnException(it, ex).then(Mono.error(ex))));
|
||||
})
|
||||
.subscriberContext(TransactionContextManager.getOrCreateContext())
|
||||
.subscriberContext(TransactionContextManager.getOrCreateContextHolder());
|
||||
.contextWrite(TransactionContextManager.getOrCreateContext())
|
||||
.contextWrite(TransactionContextManager.getOrCreateContextHolder());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user