From 18dc30b73c726e2a47e32fe5afc3e0c00b933c95 Mon Sep 17 00:00:00 2001 From: Luis Luna Date: Fri, 1 Mar 2019 10:34:47 -0600 Subject: [PATCH] Taking action invocation out of synchronized block on TokenSessionStoreInterceptor to reduce contention on the session id. --- .../interceptor/TokenSessionStoreInterceptor.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/org/apache/struts2/interceptor/TokenSessionStoreInterceptor.java b/core/src/main/java/org/apache/struts2/interceptor/TokenSessionStoreInterceptor.java index e08fb07bea..0a001f34a9 100644 --- a/core/src/main/java/org/apache/struts2/interceptor/TokenSessionStoreInterceptor.java +++ b/core/src/main/java/org/apache/struts2/interceptor/TokenSessionStoreInterceptor.java @@ -108,8 +108,13 @@ protected String handleToken(ActionInvocation invocation) throws Exception { if (!TokenHelper.validToken()) { return handleInvalidToken(invocation); } - return handleValidToken(invocation); + // we know the token name and token must be there + String key = TokenHelper.getTokenName(); + String token = TokenHelper.getToken(key); + String sessionTokenName = TokenHelper.buildTokenSessionAttributeName(key); + InvocationSessionStore.storeInvocation(sessionTokenName, token, invocation); } + return handleValidToken(invocation); } @Override @@ -155,12 +160,6 @@ protected String handleInvalidToken(ActionInvocation invocation) throws Exceptio @Override protected String handleValidToken(ActionInvocation invocation) throws Exception { - // we know the token name and token must be there - String key = TokenHelper.getTokenName(); - String token = TokenHelper.getToken(key); - String sessionTokenName = TokenHelper.buildTokenSessionAttributeName(key); - InvocationSessionStore.storeInvocation(sessionTokenName, token, invocation); - return invocation.invoke(); }