Skip to content

Commit

Permalink
Revert "Delete Session.reset (neo4j#1149)"
Browse files Browse the repository at this point in the history
This reverts commit 33447f5.
  • Loading branch information
loveleif committed Mar 8, 2023
1 parent fa6e4f8 commit e459438
Show file tree
Hide file tree
Showing 7 changed files with 951 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@ public Set<Bookmark> lastBookmarks() {
return session.lastBookmarks();
}

// Private API
public void reset()
{
Futures.blockingGet( session.resetAsync(), () -> terminateConnectionOnThreadInterrupt( "Thread interrupted while resetting the session" ) );
}

private <T> T transaction(
AccessMode mode, @SuppressWarnings("deprecation") TransactionWork<T> work, TransactionConfig config) {
// use different code path compared to async so that work is executed in the caller thread
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,29 @@ public CompletionStage<UnmanagedTransaction> beginTransactionAsync(
return newTransactionStage;
}

// Private API
public CompletionStage<Void> resetAsync()
{
return existingTransactionOrNull()
.thenAccept( tx ->
{
if ( tx != null )
{
tx.markTerminated( null );
}
} )
.thenCompose( ignore -> connectionStage )
.thenCompose( connection ->
{
if ( connection != null )
{
// there exists an active connection, send a RESET message over it
return connection.reset();
}
return completedWithNull();
} );
}

public RetryLogic retryLogic() {
return retryLogic;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ public Bookmark lastBookmark() {
return InternalBookmark.from(session.lastBookmarks());
}

public Publisher<Void> reset()
{
return createEmptyPublisher( session::resetAsync );
}

@Override
public <T> Publisher<T> close() {
return doClose();
Expand Down
Loading

0 comments on commit e459438

Please sign in to comment.