Fix #663 NPE during context stop
Avoid adding null beans protect against null beans.
This commit is contained in:
parent
69804f9e76
commit
a8e315a3f5
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue