Modified the setAttribute() method to remove the attribute

if the value is null instead of throwin an NPE.


git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7485 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
PSp..om 14 years ago
parent 842260bf9c
commit e6c9cbac12
  1. 3
      engine/src/networking/com/jme3/network/HostedConnection.java
  2. 2
      engine/src/networking/com/jme3/network/base/DefaultServer.java

@ -68,7 +68,8 @@ public interface HostedConnection extends MessageConnection
public void close( String reason ); public void close( String reason );
/** /**
* Sets a session attribute specific to this connection. * Sets a session attribute specific to this connection. If the value
* is set to null then the attribute is removed.
* *
* @return The previous session value for this key or null * @return The previous session value for this key or null
* if there was no previous value. * if there was no previous value.

@ -443,6 +443,8 @@ public class DefaultServer implements Server
public Object setAttribute( String name, Object value ) public Object setAttribute( String name, Object value )
{ {
if( value == null )
return sessionData.remove(name);
return sessionData.put(name, value); return sessionData.put(name, value);
} }

Loading…
Cancel
Save