details:   https://code.openbravo.com/erp/devel/pi/rev/75e216b9efe2
changeset: 32319:75e216b9efe2
user:      Asier Lostalé <asier.lostale <at> openbravo.com>
date:      Mon Jun 19 10:54:05 2017 +0200
summary:   fixed bug 36271: login page logs error if loaded while logging out

  Don't try to get/remove attributes from HttpSession if it's already 
invalidated.

  Note HttpSession API doesn't provide a method to check if its status, so only
  way it to catch IllegalStateException.

diffstat:

 src-core/src/org/openbravo/base/VariablesBase.java |  29 ++++++++++-----------
 1 files changed, 14 insertions(+), 15 deletions(-)

diffs (50 lines):

diff -r 1c11b256bd10 -r 75e216b9efe2 
src-core/src/org/openbravo/base/VariablesBase.java
--- a/src-core/src/org/openbravo/base/VariablesBase.java        Sat Jun 17 
00:06:44 2017 +0000
+++ b/src-core/src/org/openbravo/base/VariablesBase.java        Mon Jun 19 
10:54:05 2017 +0200
@@ -1467,6 +1467,12 @@
           session.removeAttribute(sessionName);
           e = session.getAttributeNames();
         }
+        if (!target.equals("")) {
+          session.setAttribute("TARGET", target);
+        }
+        if (targetQueryString != null) {
+          session.setAttribute("TARGETQUERYSTRING", targetQueryString);
+        }
       } else {
         for (String key : sessionAttributes.keySet()) {
           if (log4j.isDebugEnabled())
@@ -1479,25 +1485,18 @@
           }
         }
         sessionAttributes.clear();
+        if (!target.equals("")) {
+          sessionAttributes.put("TARGET", target);
+        }
+        if (targetQueryString != null) {
+          sessionAttributes.put("TARGETQUERYSTRING", targetQueryString);
+        }
       }
+    } catch (IllegalStateException ignored) {
+      // session is already invalidated: don't do anything
     } catch (Exception e) {
       log4j.error("clearSession error ", e);
     }
-    if (session != null) {
-      if (!target.equals("")) {
-        session.setAttribute("TARGET", target);
-      }
-      if (targetQueryString != null) {
-        session.setAttribute("TARGETQUERYSTRING", targetQueryString);
-      }
-    } else {
-      if (!target.equals("")) {
-        sessionAttributes.put("TARGET", target);
-      }
-      if (targetQueryString != null) {
-        sessionAttributes.put("TARGETQUERYSTRING", targetQueryString);
-      }
-    }
   }
 
   /**

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to