FELIX-1872: Fixed so that setAttribute is nullsafe

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@881061 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/http/base/src/main/java/org/apache/felix/http/base/internal/context/ServletContextImpl.java b/http/base/src/main/java/org/apache/felix/http/base/internal/context/ServletContextImpl.java
index 34e07a6..9860eb9 100644
--- a/http/base/src/main/java/org/apache/felix/http/base/internal/context/ServletContextImpl.java
+++ b/http/base/src/main/java/org/apache/felix/http/base/internal/context/ServletContextImpl.java
@@ -149,7 +149,9 @@
 
     public void setAttribute(String name, Object value)
     {
-        this.attributes.put(name, value);
+        if ((name != null) && (value != null)) {
+            this.attributes.put(name, value);
+        }
     }
 
     public void removeAttribute(String name)
diff --git a/http/base/src/test/java/org/apache/felix/http/base/internal/context/ServletContextImplTest.java b/http/base/src/test/java/org/apache/felix/http/base/internal/context/ServletContextImplTest.java
index 0026a0e..4f62064 100644
--- a/http/base/src/test/java/org/apache/felix/http/base/internal/context/ServletContextImplTest.java
+++ b/http/base/src/test/java/org/apache/felix/http/base/internal/context/ServletContextImplTest.java
@@ -111,6 +111,9 @@
 
         this.context.removeAttribute("key1");
         Assert.assertNull(this.context.getAttribute("key1"));
+
+        this.context.setAttribute("key1", null);
+        Assert.assertNull(this.context.getAttribute("key1"));
     }
 
     @Test