This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit abf45df71342f7bed2112c689d607da07e6de72a
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu May 20 13:10:12 2021 +0100

    Better align with 10.0.x and 9.0.x
---
 .../apache/catalina/session/StandardSession.java   | 57 ++++++++++------------
 1 file changed, 25 insertions(+), 32 deletions(-)

diff --git a/java/org/apache/catalina/session/StandardSession.java 
b/java/org/apache/catalina/session/StandardSession.java
index 9864946..effbc88 100644
--- a/java/org/apache/catalina/session/StandardSession.java
+++ b/java/org/apache/catalina/session/StandardSession.java
@@ -621,7 +621,6 @@ public class StandardSession implements HttpSession, 
Session, Serializable {
      */
     @Override
     public HttpSession getSession() {
-
         if (facade == null){
             if (SecurityUtil.isPackageProtectionEnabled()){
                 final StandardSession fsession = this;
@@ -636,8 +635,7 @@ public class StandardSession implements HttpSession, 
Session, Serializable {
                 facade = new StandardSessionFacade(this);
             }
         }
-        return (facade);
-
+        return facade;
     }
 
 
@@ -1375,6 +1373,8 @@ public class StandardSession implements HttpSession, 
Session, Serializable {
     public void setAttribute(String name, Object value) {
         setAttribute(name,value,true);
     }
+
+
     /**
      * Bind an object to this session, using the specified name.  If an object
      * of the same name is already bound to this session, the object is
@@ -1392,13 +1392,13 @@ public class StandardSession implements HttpSession, 
Session, Serializable {
      * @exception IllegalStateException if this method is called on an
      *  invalidated session
      */
-
     public void setAttribute(String name, Object value, boolean notify) {
 
         // Name cannot be null
-        if (name == null)
-            throw new IllegalArgumentException
-                (sm.getString("standardSession.setAttribute.namenull"));
+        if (name == null) {
+            throw new IllegalArgumentException(
+                    sm.getString("standardSession.setAttribute.namenull"));
+        }
 
         // Null value is the same as removeAttribute()
         if (value == null) {
@@ -1408,13 +1408,14 @@ public class StandardSession implements HttpSession, 
Session, Serializable {
 
         // Validate our current state
         if (!isValidInternal()) {
-            throw new IllegalStateException(sm.getString(
-                    "standardSession.setAttribute.ise", getIdInternal()));
+            throw new IllegalStateException(
+                    sm.getString("standardSession.setAttribute.ise", 
getIdInternal()));
         }
-        if ((manager != null) && manager.getContext().getDistributable() &&
-                !isAttributeDistributable(name, value) && !exclude(name, 
value)) {
-            throw new IllegalArgumentException(sm.getString(
-                    "standardSession.setAttribute.iae", name));
+
+        Context context = manager.getContext();
+
+        if (context.getDistributable() && !isAttributeDistributable(name, 
value) && !exclude(name, value)) {
+            throw new 
IllegalArgumentException(sm.getString("standardSession.setAttribute.iae", 
name));
         }
         // Construct an event with the new value
         HttpSessionBindingEvent event = null;
@@ -1428,8 +1429,8 @@ public class StandardSession implements HttpSession, 
Session, Serializable {
                 try {
                     ((HttpSessionBindingListener) value).valueBound(event);
                 } catch (Throwable t){
-                    manager.getContext().getLogger().error
-                    (sm.getString("standardSession.bindingEvent"), t);
+                    manager.getContext().getLogger().error(
+                            sm.getString("standardSession.bindingEvent"), t);
                 }
             }
         }
@@ -1450,10 +1451,11 @@ public class StandardSession implements HttpSession, 
Session, Serializable {
             }
         }
 
-        if ( !notify ) return;
+        if (!notify) {
+            return;
+        }
 
         // Notify interested application event listeners
-        Context context = manager.getContext();
         Object listeners[] = context.getApplicationEventListeners();
         if (listeners == null) {
             return;
@@ -1475,15 +1477,12 @@ public class StandardSession implements HttpSession, 
Session, Serializable {
                     context.fireContainerEvent("afterSessionAttributeReplaced",
                             listener);
                 } else {
-                    context.fireContainerEvent("beforeSessionAttributeAdded",
-                            listener);
+                    context.fireContainerEvent("beforeSessionAttributeAdded", 
listener);
                     if (event == null) {
-                        event = new HttpSessionBindingEvent
-                            (getSession(), name, value);
+                        event = new HttpSessionBindingEvent(getSession(), 
name, value);
                     }
                     listener.attributeAdded(event);
-                    context.fireContainerEvent("afterSessionAttributeAdded",
-                            listener);
+                    context.fireContainerEvent("afterSessionAttributeAdded", 
listener);
                 }
             } catch (Throwable t) {
                 ExceptionUtils.handleThrowable(t);
@@ -1492,23 +1491,20 @@ public class StandardSession implements HttpSession, 
Session, Serializable {
                         context.fireContainerEvent(
                                 "afterSessionAttributeReplaced", listener);
                     } else {
-                        
context.fireContainerEvent("afterSessionAttributeAdded",
-                                listener);
+                        
context.fireContainerEvent("afterSessionAttributeAdded", listener);
                     }
                 } catch (Exception e) {
                     // Ignore
                 }
-                manager.getContext().getLogger().error
-                    (sm.getString("standardSession.attributeEvent"), t);
+                manager.getContext().getLogger().error(
+                        sm.getString("standardSession.attributeEvent"), t);
             }
         }
-
     }
 
 
     // ------------------------------------------ HttpSession Protected Methods
 
-
     /**
      * @return the <code>isValid</code> flag for this session without any 
expiration
      * check.
@@ -1864,10 +1860,7 @@ public class StandardSession implements HttpSession, 
Session, Serializable {
                 
manager.getContext().getLogger().error(sm.getString("standardSession.attributeEvent"),
 t);
             }
         }
-
     }
-
-
 }
 
 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to