@Test void testSetAttribute() { DefaultWebApplication webApp = new DefaultWebApplication(); DefaultHttpSession session = new DefaultHttpSession(webApp); session.setSessionManager(new DefaultHttpSessionManager()); session.setAttribute("TEST", "TEST"); session.setAttribute("TEST", null); assertNull(session.getAttribute("TEST")); }
@Override public void setAttribute(String name, Object value) { verifyValid("setAttribute"); if (value != null) { boolean added = true; if (attributes.containsKey(name)) { added = false; } Object oldValue = attributes.put(name, value); if (added) { sessionManager.attributeAdded(this, name, value); } else { sessionManager.attributeReplaced(this, name, oldValue, value); } } else { removeAttribute(name); } }
DefaultHttpSession implements HttpSession { @Override public void setAttribute(String name, Object value) { verifyValid("setAttribute"); if (value != null) { boolean added = true; if (attributes.containsKey(name)) { added = false; } Object oldValue = attributes.put(name, value); if (added) { sessionManager.attributeAdded(this, name, value); } else { sessionManager.attributeReplaced(this, name, oldValue, value); } } else { removeAttribute(name); } } }
DefaultHttpSession implements HttpSession { @Override public void setAttribute(String name, Object value) { verifyValid("setAttribute"); if (value != null) { boolean added = true; if (attributes.containsKey(name)) { added = false; } Object oldValue = attributes.put(name, value); if (added) { sessionManager.attributeAdded(this, name, value); } else { sessionManager.attributeReplaced(this, name, oldValue, value); } } else { removeAttribute(name); } } DefaultHttpSession(ServletContext servletContext);  DefaultHttpSession(ServletContext servletContext, String id, boolean newFlag); }
DefaultHttpSession implements HttpSession { @Override public void setAttribute(String name, Object value) { verifyValid("setAttribute"); if (value != null) { boolean added = true; if (attributes.containsKey(name)) { added = false; } Object oldValue = attributes.put(name, value); if (added) { sessionManager.attributeAdded(this, name, value); } else { sessionManager.attributeReplaced(this, name, oldValue, value); } } else { removeAttribute(name); } } DefaultHttpSession(ServletContext servletContext);  DefaultHttpSession(ServletContext servletContext, String id, boolean newFlag); @Override Object getAttribute(String name); @Override Enumeration<String> getAttributeNames(); @Override long getCreationTime(); @Override String getId(); @Override long getLastAccessedTime(); @Override int getMaxInactiveInterval(); @Override ServletContext getServletContext(); @Override HttpSessionContext getSessionContext(); @Override Object getValue(String name); @Override String[] getValueNames(); @Override void invalidate(); @Override boolean isNew(); @Override void putValue(String name, Object value); @Override void removeAttribute(String name); @Override void removeValue(String name); @Override void setAttribute(String name, Object value); void setId(String id); @Override void setMaxInactiveInterval(int maxInactiveInterval); void setNew(boolean newFlag); void setSessionManager(HttpSessionManager sessionManager); }
DefaultHttpSession implements HttpSession { @Override public void setAttribute(String name, Object value) { verifyValid("setAttribute"); if (value != null) { boolean added = true; if (attributes.containsKey(name)) { added = false; } Object oldValue = attributes.put(name, value); if (added) { sessionManager.attributeAdded(this, name, value); } else { sessionManager.attributeReplaced(this, name, oldValue, value); } } else { removeAttribute(name); } } DefaultHttpSession(ServletContext servletContext);  DefaultHttpSession(ServletContext servletContext, String id, boolean newFlag); @Override Object getAttribute(String name); @Override Enumeration<String> getAttributeNames(); @Override long getCreationTime(); @Override String getId(); @Override long getLastAccessedTime(); @Override int getMaxInactiveInterval(); @Override ServletContext getServletContext(); @Override HttpSessionContext getSessionContext(); @Override Object getValue(String name); @Override String[] getValueNames(); @Override void invalidate(); @Override boolean isNew(); @Override void putValue(String name, Object value); @Override void removeAttribute(String name); @Override void removeValue(String name); @Override void setAttribute(String name, Object value); void setId(String id); @Override void setMaxInactiveInterval(int maxInactiveInterval); void setNew(boolean newFlag); void setSessionManager(HttpSessionManager sessionManager);  }