【发布时间】:2018-11-04 21:18:53
【问题描述】:
考虑到下面的 sn-p - 将简单的非线程安全 HashMap 传递给 SomeHandlerFunction 是否安全,它将在 SomeHandlerFunction 中的其他自动装配 bean 中使用它?
@Bean
RouterFunction<ServerResponse> request(SomeHandlerFunction handlerFunction) {
handlerFunction.setSimpleMapProperties(new HashMap());
return route(GET("/dummy"), handlerFunction);
}
@Service
class SomeHandlerFunction implements HandlerFunction {
@Autowired
List<AnotherBeans> anotherBeans;
Mono<T> handle(ServerRequest var1) {
// code...
}
}
我对 WebFlux 中的多线程模型有点了解,但是这个案例让我很困惑。
【问题讨论】:
-
不,无论使用何种技术,这样做都不安全。
标签: java spring multithreading spring-webflux reactor