From 618204b8b1c95048841275f64f6e3fbdc2b25dd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= Date: Wed, 16 Sep 2015 09:38:25 +0200 Subject: [PATCH] Component state - Fixed various bugs in stop() * Stopping only if inactive... * Calling the wrong lifecycle action... --- src/main/java/info/ebenoit/ebul/cmp/ComponentState.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main/java/info/ebenoit/ebul/cmp/ComponentState.java b/src/main/java/info/ebenoit/ebul/cmp/ComponentState.java index 7ae200b..dfaa3af 100644 --- a/src/main/java/info/ebenoit/ebul/cmp/ComponentState.java +++ b/src/main/java/info/ebenoit/ebul/cmp/ComponentState.java @@ -156,9 +156,10 @@ public final class ComponentState throw new IllegalStateException( "registry has failed" ); } this.wasActive = this.active; - if ( this.active ) { + if ( !this.active ) { return null; } + assert this.initialised; for ( final ComponentState rdepState : this.reverseDependencies ) { final Throwable t = rdepState.stop( ); @@ -168,7 +169,7 @@ public final class ComponentState } try { - this.runLifecycleAction( LifecycleStage.START ); + this.runLifecycleAction( LifecycleStage.STOP ); } catch ( final Throwable t ) { return t; } @@ -181,10 +182,6 @@ public final class ComponentState public void restart( ) throws IllegalStateException , ComponentRestartException { - if ( this.registry.hasFailed( ) ) { - throw new IllegalStateException( "registry has failed" ); - } - final Throwable t = this.stop( ); if ( t != null ) { throw new ComponentRestartException( "failed to stop" , t );