Fix #663 NPE during context stop

Avoid adding null beans
protect against null beans.
This commit is contained in:
Greg Wilkins 2016-06-15 17:27:04 +10:00
parent 69804f9e76
commit a8e315a3f5
3 changed files with 6 additions and 3 deletions

View File

@ -654,7 +654,8 @@ public class Server extends HandlerWrapper implements Attributes
@Override
public void setAttribute(String name, Object attribute)
{
addBean(attribute);
Object old=_attributes.getAttribute(name);
updateBean(old,attribute);
_attributes.setAttribute(name, attribute);
}

View File

@ -246,7 +246,7 @@ public class ContainerLifeCycle extends AbstractLifeCycle implements Container,
public boolean addBean(Object o, Managed managed)
{
if (contains(o))
if (o==null || contains(o))
return false;
Bean new_bean = new Bean(o);
@ -751,6 +751,8 @@ public class ContainerLifeCycle extends AbstractLifeCycle implements Container,
private Bean(Object b)
{
if (b==null)
throw new NullPointerException();
_bean = b;
}

View File

@ -66,8 +66,8 @@ public class ClasspathPatternTest
public void testExplicitNestedMatch()
{
assertTrue(pattern.match("org.example.Nested$Something"));
assertFalse(pattern.match("org.example.Nested$Minus"));
assertTrue(pattern.match("org.example.Nested$Other"));
}
@Test