435988 ContainerLifeCycle: beans never stopped on remove

This commit is contained in:
Jan Bartel 2014-08-27 17:11:59 +10:00
parent 4c8e2a6635
commit 0aeebc4ec0
2 changed files with 7 additions and 2 deletions

View File

@ -524,6 +524,7 @@ public class ContainerLifeCycle extends AbstractLifeCycle implements Container,
{
if (_beans.remove(bean))
{
boolean wasManaged = bean.isManaged();
unmanage(bean);
@ -534,7 +535,7 @@ public class ContainerLifeCycle extends AbstractLifeCycle implements Container,
removeEventListener((Container.Listener)bean._bean);
// stop managed beans
if (bean._managed==Managed.MANAGED && bean._bean instanceof LifeCycle)
if (wasManaged && bean._bean instanceof LifeCycle)
{
try
{

View File

@ -123,10 +123,14 @@ public class ContainerLifeCycleTest
Assert.assertEquals(1,destroyed.get());
a0.removeBean(a1);
Assert.assertEquals(3,started.get());
Assert.assertEquals(3,stopped.get());
Assert.assertEquals(1,destroyed.get());
a0.stop();
a0.destroy();
Assert.assertEquals(3,started.get());
Assert.assertEquals(2,stopped.get());
Assert.assertEquals(3,stopped.get());
Assert.assertEquals(1,destroyed.get());
a1.stop();