Programming!
Spring Security 에서 @Async 사용시 (threads) Context 공유하기
eclipse4j(Grissom)
2019. 4. 25. 20:04
기본적으로는 @Async 사용시 SecurityContext가 공유되지 않는다. 즉, JPA의 Audit를 사용한 CRUD 실행시 @Async 를 적용하면 Null 오류가 출력된다.
SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_INHERITABLETHREADLOCAL);
처리는 간단하게 SecurityConfiguration에 전파에 대한 지정만 해주면 된다.
Async 처리
https://www.baeldung.com/spring-async
How To Do @Async in Spring | Baeldung
How to enable and use @Async in Spring - from the very simple config and basic usage to the more complex executors and exception handling strategies.
www.baeldung.com
Feature
Completablefuture
ThreadPoolTaskExecutor