Skip to content

Commit

Permalink
Better method naming in BoltStateMachine
Browse files Browse the repository at this point in the history
Renamed `#terminate()` to `#markForTermination()` because the method
does not terminate anything. It only prepares the state machine to be
closed.
  • Loading branch information
lutovich authored and zhenlineo committed Jul 24, 2018
1 parent e70eee9 commit c0829aa
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
Expand Up @@ -42,7 +42,7 @@ public interface BoltStateMachine extends AutoCloseable

void handleExternalFailure( Neo4jError error, BoltResponseHandler handler ) throws BoltConnectionFatality;

void terminate();
void markForTermination();

boolean isClosed();

Expand Down
Expand Up @@ -277,7 +277,7 @@ public void stop()
{
if ( shouldClose.compareAndSet( false, true ) )
{
machine.terminate();
machine.markForTermination();

// Enqueue an empty job for close to be handled linearly
enqueueInternal( ignore ->
Expand Down
Expand Up @@ -233,7 +233,7 @@ public String id()
}

@Override
public void terminate()
public void markForTermination()
{
/*
* This is a side-channel call and we should not close anything directly.
Expand Down
Expand Up @@ -237,13 +237,13 @@ public void interruptShouldInterruptStateMachine()
}

@Test
public void stopShouldFirstTerminateStateMachine()
public void stopShouldFirstMarkStateMachineForTermination()
{
BoltConnection connection = newConnection();

connection.stop();

verify( stateMachine ).terminate();
verify( stateMachine ).markForTermination();
}

@Test
Expand All @@ -255,7 +255,7 @@ public void stopShouldCloseStateMachine()

connection.processNextBatch();

verify( stateMachine ).terminate();
verify( stateMachine ).markForTermination();
verify( stateMachine ).close();
}

Expand Down
Expand Up @@ -720,7 +720,7 @@ public void shouldInvokeResponseHandlerOnMarkFailedIfThereIsHandler() throws Exc
}

@Test
public void shouldNotFailWhenTerminatedAndPullAll() throws Exception
public void shouldNotFailWhenMarkedForTerminationAndPullAll() throws Exception
{
BoltStateMachineV1SPI spi = mock( BoltStateMachineV1SPI.class, RETURNS_MOCKS );
BoltStateMachine machine = init( newMachine( spi ) );
Expand All @@ -729,7 +729,7 @@ public void shouldNotFailWhenTerminatedAndPullAll() throws Exception

BoltResponseHandler responseHandler = mock( BoltResponseHandler.class );

machine.terminate();
machine.markForTermination();
machine.process( PullAllMessage.INSTANCE, responseHandler );

verify( spi, never() ).reportError( any() );
Expand Down

0 comments on commit c0829aa

Please sign in to comment.