-
Notifications
You must be signed in to change notification settings - Fork 192
Description
We have next state: One of the services (say ResolverService service) calling another service (say SpaceService service). Resolver service invoking method resolverA method with call to some api (say spaceA) from Space service.
@Service
class ResolverService{
SpaceService spaceService;
public boolean resolverA(Object someData){
spaceService.spaceA(someData);
....
return true;
}
}
@Service
@Transactional
class SpaceService {
public boolean spaceA(Object someData){
//Do stuff
someInsideMethodCalls(someData);
....
return true;
}
}
At scope of resolverA we have Security context - e.g. SecurityContextHolder.getContext().getAuthentication()
holds relevant jwt authentication object.
When we going inside of SpaceService#spaceA - Security context has been nullified (e.g. SecurityContextHolder.getContext().getAuthentication()
returns null).
while in given case i would expect to get this context.
If @Transactional
attribute removed from SpaceService class - Security context presented and passed as it should.
Security context should be passed correctly if @Transacitonal attribute in use.