Skip to content

Commit 2a27bf2

Browse files
committed
Updated error code according to server response
1 parent f6f6d5d commit 2a27bf2

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

driver/src/main/java/org/neo4j/driver/internal/ClusteredNetworkSession.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public StatementResult run( Statement statement )
5353
}
5454
catch ( ClientException e )
5555
{
56-
if ( e.code().equals( "Neo.ClientError.General.ForbiddenOnFollower" ) )
56+
if ( e.code().equals( "Neo.ClientError.Cluster.NotALeader" ) )
5757
{
5858
onError.onWriteFailure( connection.address() );
5959
throw new SessionExpiredException(

driver/src/main/java/org/neo4j/driver/internal/ClusteredStatementResult.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,6 @@ private SessionExpiredException failedWrite()
256256

257257
private boolean isFailedToWrite( ClientException e )
258258
{
259-
return e.code().equals( "Neo.ClientError.General.ForbiddenOnFollower" );
259+
return e.code().equals( "Neo.ClientError.Cluster.NotALeader" );
260260
}
261261
}

driver/src/test/java/org/neo4j/driver/internal/ClusteredNetworkSessionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public void shouldHandleConnectionFailures()
8888
public void shouldHandleWriteFailures()
8989
{
9090
// Given
91-
doThrow( new ClientException( "Neo.ClientError.General.ForbiddenOnFollower", "oh no!" ) ).
91+
doThrow( new ClientException( "Neo.ClientError.Cluster.NotALeader", "oh no!" ) ).
9292
when( connection ).run( anyString(), any( Map.class ), any( Collector.class ) );
9393
ClusteredNetworkSession session =
9494
new ClusteredNetworkSession( connection, onError, mock( Logger.class ) );

driver/src/test/java/org/neo4j/driver/internal/ClusteredStatementResultTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public void shouldHandleWriteFailureOnConsume()
6868
{
6969
// Given
7070
when( delegate.consume() )
71-
.thenThrow( new ClientException( "Neo.ClientError.General.ForbiddenOnFollower", "oh no!" ) );
71+
.thenThrow( new ClientException( "Neo.ClientError.Cluster.NotALeader", "oh no!" ) );
7272
ClusteredStatementResult result =
7373
new ClusteredStatementResult( delegate, LOCALHOST, onError );
7474

@@ -117,7 +117,7 @@ public void shouldHandleWriteFailureOnHasNext()
117117
{
118118
// Given
119119
when( delegate.hasNext() )
120-
.thenThrow( new ClientException( "Neo.ClientError.General.ForbiddenOnFollower", "oh no!" ) );
120+
.thenThrow( new ClientException( "Neo.ClientError.Cluster.NotALeader", "oh no!" ) );
121121
ClusteredStatementResult result =
122122
new ClusteredStatementResult( delegate, LOCALHOST, onError );
123123

@@ -166,7 +166,7 @@ public void shouldHandleWriteFailureOnKeys()
166166
{
167167
// Given
168168
when( delegate.keys() )
169-
.thenThrow( new ClientException( "Neo.ClientError.General.ForbiddenOnFollower", "oh no!" ) );
169+
.thenThrow( new ClientException( "Neo.ClientError.Cluster.NotALeader", "oh no!" ) );
170170
ClusteredStatementResult result =
171171
new ClusteredStatementResult( delegate, LOCALHOST, onError );
172172

@@ -215,7 +215,7 @@ public void shouldHandleWriteFailureOnList()
215215
{
216216
// Given
217217
when( delegate.list() )
218-
.thenThrow( new ClientException( "Neo.ClientError.General.ForbiddenOnFollower", "oh no!" ) );
218+
.thenThrow( new ClientException( "Neo.ClientError.Cluster.NotALeader", "oh no!" ) );
219219
ClusteredStatementResult result =
220220
new ClusteredStatementResult( delegate, LOCALHOST, onError );
221221

@@ -264,7 +264,7 @@ public void shouldHandleWriteFailureOnNext()
264264
{
265265
// Given
266266
when( delegate.next() )
267-
.thenThrow( new ClientException( "Neo.ClientError.General.ForbiddenOnFollower", "oh no!" ) );
267+
.thenThrow( new ClientException( "Neo.ClientError.Cluster.NotALeader", "oh no!" ) );
268268
ClusteredStatementResult result =
269269
new ClusteredStatementResult( delegate, LOCALHOST, onError );
270270

@@ -313,7 +313,7 @@ public void shouldHandleWriteFailureOnPeek()
313313
{
314314
// Given
315315
when( delegate.peek() )
316-
.thenThrow( new ClientException( "Neo.ClientError.General.ForbiddenOnFollower", "oh no!" ) );
316+
.thenThrow( new ClientException( "Neo.ClientError.Cluster.NotALeader", "oh no!" ) );
317317
ClusteredStatementResult result =
318318
new ClusteredStatementResult( delegate, LOCALHOST, onError );
319319

@@ -362,7 +362,7 @@ public void shouldHandleWriteFailureOnSingle()
362362
{
363363
// Given
364364
when( delegate.single() )
365-
.thenThrow( new ClientException( "Neo.ClientError.General.ForbiddenOnFollower", "oh no!" ) );
365+
.thenThrow( new ClientException( "Neo.ClientError.Cluster.NotALeader", "oh no!" ) );
366366
ClusteredStatementResult result =
367367
new ClusteredStatementResult( delegate, LOCALHOST, onError );
368368

driver/src/test/resources/not_able_to_write_server.script

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
C: RUN "CREATE ()" {}
77
C: PULL_ALL
8-
S: FAILURE {"code": "Neo.ClientError.General.ForbiddenOnFollower", "message": "blabla"}
8+
S: FAILURE {"code": "Neo.ClientError.Cluster.NotALeader", "message": "blabla"}
99
S: IGNORED
1010
C: ACK_FAILURE
1111
S: SUCCESS {}

0 commit comments

Comments
 (0)