【发布时间】:2021-05-31 02:57:12
【问题描述】:
我正在使用此代码:
Map<String, ?> result = Flux.range(1, 2)
.parallel(2)
.runOn(Schedulers.parallel())
.map(this::mapWithSecurityContextHolder)
.sequential()
.publishOn(Schedulers.single())
.collect(Collectors.toMap(Pair::getFirst, Pair::getSecond))
.block();
mapWithSecurityContextHolder 代码是:
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
Claims claims = (Claims) authentication.getDetails();
所以,authentication 是 null,因为通量线程不是请求线程并且引发了 NullPointerException。
有什么想法吗?
【问题讨论】:
标签: spring spring-security spring-webflux