# HG changeset patch
# User Rafa Alonso <rafael.alonso@openbravo.com>
# Date 1408442402 -7200
#      Tue Aug 19 12:00:02 2014 +0200
# Node ID 292e42c687269c52234dcfdbf0e73c9c6a2fff84
# Parent  ac581689470e93db905515067f44ff1f78f5d589
Fixes issue 27370: If the session is invalidated while retriving session attributes,
- the session will end
- the console log will report that the session was invalidated while retriving attributes

diff -r ac581689470e -r 292e42c68726 src-core/src/org/openbravo/base/VariablesBase.java
--- a/src-core/src/org/openbravo/base/VariablesBase.java  Mon Aug 18 20:50:33 2014 +0000
+++ b/src-core/src/org/openbravo/base/VariablesBase.java  Tue Aug 19 12:00:02 2014 +0200
@@ -1344,7 +1344,9 @@
       if (!attribute.equalsIgnoreCase("menuVertical"))
         if (log4j.isDebugEnabled())
           log4j.debug("Set session attribute: " + attribute + ":..." + value.toString());
-    } catch (Exception e) {
+    } catch (final IllegalStateException ise) {
+      throw new IllegalStateException(ise);
+    } catch (final Exception e) {
       log4j.error("setSessionValue error: " + attribute + ":..." + value);
     }
   }
diff -r ac581689470e -r 292e42c68726 src/org/openbravo/base/secureApp/HttpSecureAppServlet.java
--- a/src/org/openbravo/base/secureApp/HttpSecureAppServlet.java  Mon Aug 18 20:50:33 2014 +0000
+++ b/src/org/openbravo/base/secureApp/HttpSecureAppServlet.java  Tue Aug 19 12:00:02 2014 +0200
@@ -346,7 +346,10 @@
       roleError.setType("Error");
       roleError.setMessage(msg);
       invalidLogin(request, response, roleError);
-
+      return;
+    } catch (final IllegalStateException ise) {
+      log4j.error("HTTPSecureAppServlet.service() - exception caught: ", ise);
+      invalidateSession(request);
       return;
     } catch (final Exception e) {
       // Re-login
# HG changeset patch
# User Rafa Alonso <rafael.alonso@openbravo.com>
# Date 1408444744 -7200
#      Tue Aug 19 12:39:04 2014 +0200
# Node ID cf2476a790bf9d816043c7262d0e3380db2fe3ad
# Parent  292e42c687269c52234dcfdbf0e73c9c6a2fff84
Fixes issue 27370: If the session is invalidated while retriving or removing session attributes,
- the session will end
- the console log will properly report that the session was invalidated

Methods involved (setSessionValue was fixed wth the above changeset):
- getSessionValue
- removeSessionValue

diff -r 292e42c68726 -r cf2476a790bf src-core/src/org/openbravo/base/VariablesBase.java
--- a/src-core/src/org/openbravo/base/VariablesBase.java  Tue Aug 19 12:00:02 2014 +0200
+++ b/src-core/src/org/openbravo/base/VariablesBase.java  Tue Aug 19 12:39:04 2014 +0200
@@ -1321,6 +1321,8 @@
       auxStr = (String) session.getAttribute(sessionAttribute.toUpperCase());
       if (auxStr == null || auxStr.trim().equals(""))
         auxStr = defaultValue;
+    } catch (final IllegalStateException ise) {
+      throw new IllegalStateException(ise);
     } catch (Exception e) {
       auxStr = defaultValue;
     }
@@ -1362,7 +1364,8 @@
       if (log4j.isDebugEnabled())
         log4j.debug("Remove session attribute: " + attribute + ":..." + getSessionValue(attribute));
       session.removeAttribute(attribute.toUpperCase());
-
+    } catch (final IllegalStateException ise) {
+      throw new IllegalStateException(ise);
     } catch (Exception e) {
       log4j.error("removeSessionValue error: " + attribute);
     }
