struts git commit: WW-4600 Adds additional check if session was invalidated

2016-02-03 Thread lukaszlenart
Repository: struts
Updated Branches:
  refs/heads/support-2-3 c44566bd2 -> 85373951b


WW-4600 Adds additional check if session was invalidated


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/85373951
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/85373951
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/85373951

Branch: refs/heads/support-2-3
Commit: 85373951b7dfe55a92a76c87ee8faf50233bf07c
Parents: c44566b
Author: Lukasz Lenart 
Authored: Wed Feb 3 09:28:21 2016 +0100
Committer: Lukasz Lenart 
Committed: Wed Feb 3 09:33:50 2016 +0100

--
 .../interceptor/MessageStoreInterceptor.java|  43 +++
 .../MessageStoreInterceptorTest.java| 116 ++-
 2 files changed, 135 insertions(+), 24 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/struts/blob/85373951/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 f34cee0..97e1693 100644
--- 
a/core/src/main/java/org/apache/struts2/interceptor/MessageStoreInterceptor.java
+++ 
b/core/src/main/java/org/apache/struts2/interceptor/MessageStoreInterceptor.java
@@ -272,41 +272,42 @@ 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 [#0] 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) {
-if (LOG.isDebugEnabled()) {
-LOG.debug("Could not store action ["+action+"] 
error/messages into session, because session hasn't been opened yet.");
-}
-return;
-}
-
-if (LOG.isDebugEnabled()) {
-LOG.debug("store action ["+action+"] error/messages into 
session ");
-}
+if (action instanceof ValidationAware) {
+LOG.debug("Storing action [#0] error/messages into session ", 
action);
 
 ValidationAware validationAwareAction = (ValidationAware) 
action;
 session.put(actionErrorsSessionKey, 
validationAwareAction.getActionErrors());
 session.put(actionMessagesSessionKey, 
validationAwareAction.getActionMessages());
 session.put(fieldErrorsSessionKey, 
validationAwareAction.getFieldErrors());
 
-} else if(LOG.isDebugEnabled()) {
-if (isCommitted) {
-LOG.debug("Response was already committed, cannot store 
messages!");
-} else {
-LOG.debug("Action [" + action + "] is not ValidationAware, 
no message / error that are storeable");
-}
+} else {
+LOG.debug("Action [#0] is not ValidationAware, no message / 
error that are storeable", action);
 }
 }
 }

http://git-wip-us.apache.org/repos/asf/struts/blob/85373951/core/src/test/java/org/apache/struts2/interceptor/MessageStoreInterceptorTest.java

struts git commit: WW-4600 Adds additional check if session was invalidated

2016-02-03 Thread lukaszlenart
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 {
-