GitHub user ewesten added a comment to the discussion: [Question] how to ensure 
child threads have same subject as parent thread

Hello,

thanks for the reply, but I am not getting it yet (sorry if I am slow). 

Here is my basic coding (attempting to adopt the proposal above).
However it is not working in Shiro 2.0.6. (In 2.0.3 it was working even without 
`bind()` and `associateWith`. )

```
Runnable task = () -> {
  try {
    ThreadContext.bind(SecurityUtils.getSecurityManager());
    // my code with access control check based on principal
  } finally {
    ThreadContext.remove();
  }
};

Subject subject = SecurityUtils.getSubject();
subject.associateWith(task);
Thread t = new Thread(task, "myworker");
t.start();
```

Essentially it is not clear to me how to obtain / propagate  the correct 
security manager in the child thread.

Regards, Eric

GitHub link: 
https://github.com/apache/shiro/discussions/2413#discussioncomment-15168140

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to