Skip to content

Commit c788f45

Browse files
committed
Fixed couple errors after rebase
Also added unit tests for `Futures#asCompletionException()`.
1 parent cc8fc7e commit c788f45

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,13 +371,13 @@ private BiFunction<Void,Throwable,Void> handleCommitOrRollback( Throwable cursor
371371
{
372372
if ( cursorFailure != null && commitOrRollbackError != null )
373373
{
374-
Throwable cause1 = completionErrorCause( cursorFailure );
375-
Throwable cause2 = completionErrorCause( commitOrRollbackError );
374+
Throwable cause1 = Futures.completionExceptionCause( cursorFailure );
375+
Throwable cause2 = Futures.completionExceptionCause( commitOrRollbackError );
376376
if ( cause1 != cause2 )
377377
{
378378
cause1.addSuppressed( cause2 );
379379
}
380-
throw new CompletionException( cause1 );
380+
throw Futures.asCompletionException( cause1 );
381381
}
382382
else if ( cursorFailure != null )
383383
{

driver/src/test/java/org/neo4j/driver/internal/util/FuturesTest.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,14 +335,29 @@ public void shouldGetCauseFromCompletionException()
335335
RuntimeException error = new RuntimeException( "Hello" );
336336
CompletionException completionException = new CompletionException( error );
337337

338-
assertEquals( error, Futures.completionErrorCause( completionException ) );
338+
assertEquals( error, Futures.completionExceptionCause( completionException ) );
339339
}
340340

341341
@Test
342342
public void shouldReturnSameExceptionWhenItIsNotCompletionException()
343343
{
344344
RuntimeException error = new RuntimeException( "Hello" );
345345

346-
assertEquals( error, Futures.completionErrorCause( error ) );
346+
assertEquals( error, Futures.completionExceptionCause( error ) );
347+
}
348+
349+
@Test
350+
public void shouldWrapWithCompletionException()
351+
{
352+
RuntimeException error = new RuntimeException( "Hello" );
353+
CompletionException completionException = Futures.asCompletionException( error );
354+
assertEquals( error, completionException.getCause() );
355+
}
356+
357+
@Test
358+
public void shouldKeepCompletionExceptionAsIs()
359+
{
360+
CompletionException error = new CompletionException( new RuntimeException( "Hello" ) );
361+
assertEquals( error, Futures.asCompletionException( error ) );
347362
}
348363
}

0 commit comments

Comments
 (0)