commit | aac00fd94d57630ace4deaa7636fd789293cb988 | [log] [tgz] |
---|---|---|
author | Sten Roger Sandvik <srs@apache.org> | Mon Nov 16 23:54:11 2009 +0000 |
committer | Sten Roger Sandvik <srs@apache.org> | Mon Nov 16 23:54:11 2009 +0000 |
tree | 270942fef34eba7e7226d7c1fbfaa5a5cee61bbd | |
parent | 5b20cf4b2cc001898f6dfff3acb48481e5802fec [diff] |
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