Adapt to API changes in the latest reactor snapshot

This commit is contained in:
Stephane Nicoll
2020-08-04 11:41:30 +02:00
parent 93b53dae29
commit 673f83e388
5 changed files with 25 additions and 23 deletions

View File

@@ -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")

View File

@@ -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());
});
}

View File

@@ -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());
}
/**