Component state - Fixed various bugs in stop()

* Stopping only if inactive...
* Calling the wrong lifecycle action...
This commit is contained in:
Emmanuel BENOîT 2015-09-16 09:38:25 +02:00
parent 2fa4227e5a
commit 618204b8b1

View file

@ -156,9 +156,10 @@ public final class ComponentState
throw new IllegalStateException( "registry has failed" ); throw new IllegalStateException( "registry has failed" );
} }
this.wasActive = this.active; this.wasActive = this.active;
if ( this.active ) { if ( !this.active ) {
return null; return null;
} }
assert this.initialised;
for ( final ComponentState rdepState : this.reverseDependencies ) { for ( final ComponentState rdepState : this.reverseDependencies ) {
final Throwable t = rdepState.stop( ); final Throwable t = rdepState.stop( );
@ -168,7 +169,7 @@ public final class ComponentState
} }
try { try {
this.runLifecycleAction( LifecycleStage.START ); this.runLifecycleAction( LifecycleStage.STOP );
} catch ( final Throwable t ) { } catch ( final Throwable t ) {
return t; return t;
} }
@ -181,10 +182,6 @@ public final class ComponentState
public void restart( ) public void restart( )
throws IllegalStateException , ComponentRestartException throws IllegalStateException , ComponentRestartException
{ {
if ( this.registry.hasFailed( ) ) {
throw new IllegalStateException( "registry has failed" );
}
final Throwable t = this.stop( ); final Throwable t = this.stop( );
if ( t != null ) { if ( t != null ) {
throw new ComponentRestartException( "failed to stop" , t ); throw new ComponentRestartException( "failed to stop" , t );