File tree 2 files changed +25
-5
lines changed
driver/src/main/java/org/neo4j/driver/internal
2 files changed +25
-5
lines changed Original file line number Diff line number Diff line change 18
18
*/
19
19
package org .neo4j .driver .internal .async ;
20
20
21
+ import java .util .Arrays ;
21
22
import java .util .EnumSet ;
22
23
import java .util .concurrent .CompletionException ;
23
24
import java .util .concurrent .CompletionStage ;
@@ -229,7 +230,29 @@ public boolean isOpen()
229
230
230
231
public void markTerminated ( Throwable cause )
231
232
{
232
- state = StateHolder .terminatedWith ( cause );
233
+ if ( state .value == State .TERMINATED )
234
+ {
235
+ if ( state .causeOfTermination != null )
236
+ {
237
+ addSuppressedWhenNotCaptured ( state .causeOfTermination , cause );
238
+ }
239
+ }
240
+ else
241
+ {
242
+ state = StateHolder .terminatedWith ( cause );
243
+ }
244
+ }
245
+
246
+ private void addSuppressedWhenNotCaptured ( Throwable currentCause , Throwable newCause )
247
+ {
248
+ if ( currentCause != newCause )
249
+ {
250
+ boolean noneMatch = Arrays .stream ( currentCause .getSuppressed () ).noneMatch ( suppressed -> suppressed == newCause );
251
+ if ( noneMatch )
252
+ {
253
+ currentCause .addSuppressed ( newCause );
254
+ }
255
+ }
233
256
}
234
257
235
258
public Connection connection ()
Original file line number Diff line number Diff line change @@ -45,9 +45,6 @@ public void afterFailure( Throwable error )
45
45
// always mark transaction as terminated because every error is "acknowledged" with a RESET message
46
46
// so database forgets about the transaction after the first error
47
47
// such transaction should not attempt to commit and can be considered as rolled back
48
- if ( tx .isOpen () )
49
- {
50
- tx .markTerminated ( error );
51
- }
48
+ tx .markTerminated ( error );
52
49
}
53
50
}
You can’t perform that action at this time.
0 commit comments