spring security strategy MODE_INHERITABLETHREADLOCAL. Why?

北城余情 提交于 2020-01-16 01:08:14

问题


I understand how and what happens when we use MODE_THREADLOCAL and MODE_INHERITABLETHREADLOCAL in Spring Security Strategy. What I don't understand is, why would someone use MODE_THREADLOCAL over MODE_INHERITABLETHREADLOCAL.

  1. Is there a memory impact with using one over the other. If so, is it significant enough?
  2. What is a typical business/functional usecase for using MODE_INHERITABLETHREADLOCAL?
  3. Any performance different with using one over the other?

回答1:


  1. The memory impact of using the two is negligible

  2. In some environments, it is common to spin up new Threads to do background tasks. Sometimes developers do not want the Thread that is created to contain a SecurityContext automatically. In these instances, MODE_THREADLOCAL is preferable. If you spin up a task on behalf of the current user, then it may be desirable to propagate the SecurityContext. In this instance MODE_INHERITABLETHREADLOCAL would be preferrable.

  3. Performance between the two strategies is negligible



来源:https://stackoverflow.com/questions/31967886/spring-security-strategy-mode-inheritablethreadlocal-why

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!