thread-local

Do operations on ThreadLocal have to be synchronized?

百般思念 提交于 2021-02-07 12:52:47
问题 Here is the code I've stumbled across: class TransactionContextHolder { private static final ThreadLocal<TransactionContext> currentTransactionContext = new NamedInheritableThreadLocal<TransactionContext>( "Test Transaction Context"); static TransactionContext getCurrentTransactionContext() { return currentTransactionContext.get(); } static void setCurrentTransactionContext(TransactionContext transactionContext) { currentTransactionContext.set(transactionContext); } static TransactionContext

SecurityContextHolder gives wrong User details

点点圈 提交于 2020-12-01 07:21:08
问题 In my Application, We are capturing User details of each transaction from SecurityContextHolder Authentication object. But it gives wrong UserID it seems. Below are the code snippet for your reference. SecurityContext.xml spring-security-3.2 -- <security:http auto-config="true"> <!-- Restrict URLs based on role --> <security:headers> <security:cache-control/> <security:content-type-options/> <security:frame-options policy="DENY"/> <security:xss-protection/> </security:headers> <security