Author: markt Date: Mon Feb 26 09:48:14 2018 New Revision: 1825349 URL: http://svn.apache.org/viewvc?rev=1825349&view=rev Log: Code clean-up. No functional change.
Modified: tomcat/trunk/java/org/apache/catalina/session/StandardSession.java Modified: tomcat/trunk/java/org/apache/catalina/session/StandardSession.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/session/StandardSession.java?rev=1825349&r1=1825348&r2=1825349&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/session/StandardSession.java (original) +++ tomcat/trunk/java/org/apache/catalina/session/StandardSession.java Mon Feb 26 09:48:14 2018 @@ -1375,6 +1375,8 @@ public class StandardSession implements 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 +1394,13 @@ public class StandardSession implements * @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 +1410,13 @@ public class StandardSession implements // 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)); + throw new IllegalArgumentException( + sm.getString("standardSession.setAttribute.iae", name)); } // Construct an event with the new value HttpSessionBindingEvent event = null; @@ -1428,8 +1430,8 @@ public class StandardSession implements 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); } } } @@ -1438,76 +1440,68 @@ public class StandardSession implements Object unbound = attributes.put(name, value); // Call the valueUnbound() method if necessary - if (notify && (unbound != null) && (unbound != value) && - (unbound instanceof HttpSessionBindingListener)) { + if (notify && (unbound instanceof HttpSessionBindingListener) && (unbound != value)) { try { - ((HttpSessionBindingListener) unbound).valueUnbound - (new HttpSessionBindingEvent(getSession(), name)); + ((HttpSessionBindingListener) unbound).valueUnbound( + new HttpSessionBindingEvent(getSession(), name)); } catch (Throwable t) { ExceptionUtils.handleThrowable(t); - manager.getContext().getLogger().error - (sm.getString("standardSession.bindingEvent"), t); + manager.getContext().getLogger().error( + sm.getString("standardSession.bindingEvent"), t); } } - if ( !notify ) return; + if (!notify) { + return; + } // Notify interested application event listeners Context context = manager.getContext(); Object listeners[] = context.getApplicationEventListeners(); - if (listeners == null) + if (listeners == null) { return; + } for (int i = 0; i < listeners.length; i++) { - if (!(listeners[i] instanceof HttpSessionAttributeListener)) + if (!(listeners[i] instanceof HttpSessionAttributeListener)) { continue; - HttpSessionAttributeListener listener = - (HttpSessionAttributeListener) listeners[i]; + } + HttpSessionAttributeListener listener = (HttpSessionAttributeListener) listeners[i]; try { if (unbound != null) { - context.fireContainerEvent("beforeSessionAttributeReplaced", - listener); + context.fireContainerEvent("beforeSessionAttributeReplaced", listener); if (event == null) { - event = new HttpSessionBindingEvent - (getSession(), name, unbound); + event = new HttpSessionBindingEvent(getSession(), name, unbound); } listener.attributeReplaced(event); - context.fireContainerEvent("afterSessionAttributeReplaced", - listener); + 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); try { if (unbound != null) { - context.fireContainerEvent( - "afterSessionAttributeReplaced", listener); + 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. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org