From c0829aade0f2b17ce3648cf213f6731995749c29 Mon Sep 17 00:00:00 2001 From: lutovich Date: Thu, 12 Jul 2018 17:07:56 +0200 Subject: [PATCH] Better method naming in BoltStateMachine Renamed `#terminate()` to `#markForTermination()` because the method does not terminate anything. It only prepares the state machine to be closed. --- .../main/java/org/neo4j/bolt/runtime/BoltStateMachine.java | 2 +- .../java/org/neo4j/bolt/runtime/DefaultBoltConnection.java | 2 +- .../java/org/neo4j/bolt/v1/runtime/BoltStateMachineV1.java | 2 +- .../org/neo4j/bolt/runtime/DefaultBoltConnectionTest.java | 6 +++--- .../org/neo4j/bolt/v1/runtime/BoltStateMachineTest.java | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/community/bolt/src/main/java/org/neo4j/bolt/runtime/BoltStateMachine.java b/community/bolt/src/main/java/org/neo4j/bolt/runtime/BoltStateMachine.java index 77254539a1a9b..748063d21bc79 100644 --- a/community/bolt/src/main/java/org/neo4j/bolt/runtime/BoltStateMachine.java +++ b/community/bolt/src/main/java/org/neo4j/bolt/runtime/BoltStateMachine.java @@ -42,7 +42,7 @@ public interface BoltStateMachine extends AutoCloseable void handleExternalFailure( Neo4jError error, BoltResponseHandler handler ) throws BoltConnectionFatality; - void terminate(); + void markForTermination(); boolean isClosed(); diff --git a/community/bolt/src/main/java/org/neo4j/bolt/runtime/DefaultBoltConnection.java b/community/bolt/src/main/java/org/neo4j/bolt/runtime/DefaultBoltConnection.java index 84143da71297e..5c7a13ce4cb79 100644 --- a/community/bolt/src/main/java/org/neo4j/bolt/runtime/DefaultBoltConnection.java +++ b/community/bolt/src/main/java/org/neo4j/bolt/runtime/DefaultBoltConnection.java @@ -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 -> diff --git a/community/bolt/src/main/java/org/neo4j/bolt/v1/runtime/BoltStateMachineV1.java b/community/bolt/src/main/java/org/neo4j/bolt/v1/runtime/BoltStateMachineV1.java index a5de0161a96e8..3651015ebe94a 100644 --- a/community/bolt/src/main/java/org/neo4j/bolt/v1/runtime/BoltStateMachineV1.java +++ b/community/bolt/src/main/java/org/neo4j/bolt/v1/runtime/BoltStateMachineV1.java @@ -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. diff --git a/community/bolt/src/test/java/org/neo4j/bolt/runtime/DefaultBoltConnectionTest.java b/community/bolt/src/test/java/org/neo4j/bolt/runtime/DefaultBoltConnectionTest.java index 4ba43a9906115..979191a2722a1 100644 --- a/community/bolt/src/test/java/org/neo4j/bolt/runtime/DefaultBoltConnectionTest.java +++ b/community/bolt/src/test/java/org/neo4j/bolt/runtime/DefaultBoltConnectionTest.java @@ -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 @@ -255,7 +255,7 @@ public void stopShouldCloseStateMachine() connection.processNextBatch(); - verify( stateMachine ).terminate(); + verify( stateMachine ).markForTermination(); verify( stateMachine ).close(); } diff --git a/community/bolt/src/test/java/org/neo4j/bolt/v1/runtime/BoltStateMachineTest.java b/community/bolt/src/test/java/org/neo4j/bolt/v1/runtime/BoltStateMachineTest.java index f89146954d000..fbdfc713912bb 100644 --- a/community/bolt/src/test/java/org/neo4j/bolt/v1/runtime/BoltStateMachineTest.java +++ b/community/bolt/src/test/java/org/neo4j/bolt/v1/runtime/BoltStateMachineTest.java @@ -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 ) ); @@ -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() );