Repository: struts
Updated Branches:
refs/heads/master 94691e0af -> d8b6602e6
WW-4600 Adds additional check if session was invalidated
Conflicts:
core/src/main/java/org/apache/struts2/interceptor/MessageStoreInterceptor.java
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/d8b6602e
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/d8b6602e
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/d8b6602e
Branch: refs/heads/master
Commit: d8b6602e6fd5d4943217ea98dac6be69db9a615d
Parents: 94691e0
Author: Lukasz Lenart
Authored: Wed Feb 3 09:28:21 2016 +0100
Committer: Lukasz Lenart
Committed: Wed Feb 3 09:37:19 2016 +0100
--
.../interceptor/MessageStoreInterceptor.java| 39 ---
.../MessageStoreInterceptorTest.java| 116 ++-
2 files changed, 135 insertions(+), 20 deletions(-)
--
http://git-wip-us.apache.org/repos/asf/struts/blob/d8b6602e/core/src/main/java/org/apache/struts2/interceptor/MessageStoreInterceptor.java
--
diff --git
a/core/src/main/java/org/apache/struts2/interceptor/MessageStoreInterceptor.java
b/core/src/main/java/org/apache/struts2/interceptor/MessageStoreInterceptor.java
index 8ff2522..848c5bf 100644
---
a/core/src/main/java/org/apache/struts2/interceptor/MessageStoreInterceptor.java
+++
b/core/src/main/java/org/apache/struts2/interceptor/MessageStoreInterceptor.java
@@ -60,7 +60,7 @@ import java.util.Map;
*
*
*
- * In the 'AUTOMATIC' mode, the interceptor will always retrieve the stored
action's message / errors
+ * In the 'AUTOMATIC' mode, the interceptor will always retrieve the stored
action's message / errors
* and field errors and put them back into the {@link ValidationAware} action,
and after Action execution,
* if the {@link com.opensymphony.xwork2.Result} is an instance of {@link
ServletRedirectResult}, the action's message / errors
* and field errors into automatically be stored in the HTTP session..
@@ -269,25 +269,34 @@ public class MessageStoreInterceptor extends
AbstractInterceptor {
*/
protected void after(ActionInvocation invocation, String result) throws
Exception {
+boolean isCommitted = ServletActionContext.getResponse().isCommitted();
+if (isCommitted) {
+LOG.trace("Response was already committed, cannot store
messages!");
+return;
+}
+
+boolean isInvalidated =
ServletActionContext.getRequest().getSession(false) == null;
+if (isInvalidated) {
+LOG.trace("Session was invalidated or never created, cannot store
messages!");
+return;
+}
+
+Map session =
invocation.getInvocationContext().getSession();
+if (session == null) {
+LOG.trace("Could not store action [{}] error/messages into
session, because session hasn't been opened yet.", invocation.getAction());
+return;
+}
+
String reqOperationMode = getRequestOperationMode(invocation);
boolean isRedirect = invocation.getResult() instanceof
ServletRedirectResult;
-boolean isCommitted = ServletActionContext.getResponse().isCommitted();
if (STORE_MODE.equalsIgnoreCase(reqOperationMode) ||
STORE_MODE.equalsIgnoreCase(operationMode) ||
(AUTOMATIC_MODE.equalsIgnoreCase(operationMode) &&
isRedirect)) {
Object action = invocation.getAction();
-if (action instanceof ValidationAware && !isCommitted) {
-// store error / messages into session
-Map session =
invocation.getInvocationContext().getSession();
-
-if (session == null) {
-LOG.debug("Could not store action [{}] error/messages into
session, because session hasn't been opened yet.", action);
-return;
-}
-
-LOG.debug("Store action [{}] error/messages into session.",
action);
+if (action instanceof ValidationAware) {
+LOG.debug("Storing action [{}] error/messages into session ",
action);
ValidationAware validationAwareAction = (ValidationAware)
action;
session.put(actionErrorsSessionKey,
validationAwareAction.getActionErrors());
@@ -295,11 +304,7 @@ public class MessageStoreInterceptor extends
AbstractInterceptor {
session.put(fieldErrorsSessionKey,
validationAwareAction.getFieldErrors());
} else {
-if (isCommitted) {
-LOG.debug("Response was already committed, cannot store
messages!");
-} else {
-