From e6c9cbac1243f7e8b2a5cf62f157d9804dd66b98 Mon Sep 17 00:00:00 2001 From: "PSp..om" Date: Wed, 11 May 2011 17:12:01 +0000 Subject: [PATCH] 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 --- engine/src/networking/com/jme3/network/HostedConnection.java | 3 ++- engine/src/networking/com/jme3/network/base/DefaultServer.java | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/engine/src/networking/com/jme3/network/HostedConnection.java b/engine/src/networking/com/jme3/network/HostedConnection.java index 6b6ebfb82..980f89141 100644 --- a/engine/src/networking/com/jme3/network/HostedConnection.java +++ b/engine/src/networking/com/jme3/network/HostedConnection.java @@ -68,7 +68,8 @@ public interface HostedConnection extends MessageConnection 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 * if there was no previous value. diff --git a/engine/src/networking/com/jme3/network/base/DefaultServer.java b/engine/src/networking/com/jme3/network/base/DefaultServer.java index e5b88c297..235334641 100644 --- a/engine/src/networking/com/jme3/network/base/DefaultServer.java +++ b/engine/src/networking/com/jme3/network/base/DefaultServer.java @@ -443,6 +443,8 @@ public class DefaultServer implements Server public Object setAttribute( String name, Object value ) { + if( value == null ) + return sessionData.remove(name); return sessionData.put(name, value); }