Skip to content

Commit e459438

Browse files
committed
Revert "Delete Session.reset (neo4j#1149)"
This reverts commit 33447f5.
1 parent fa6e4f8 commit e459438

File tree

7 files changed

+951
-0
lines changed

7 files changed

+951
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,12 @@ public Set<Bookmark> lastBookmarks() {
140140
return session.lastBookmarks();
141141
}
142142

143+
// Private API
144+
public void reset()
145+
{
146+
Futures.blockingGet( session.resetAsync(), () -> terminateConnectionOnThreadInterrupt( "Thread interrupted while resetting the session" ) );
147+
}
148+
143149
private <T> T transaction(
144150
AccessMode mode, @SuppressWarnings("deprecation") TransactionWork<T> work, TransactionConfig config) {
145151
// use different code path compared to async so that work is executed in the caller thread

driver/src/main/java/org/neo4j/driver/internal/async/NetworkSession.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,29 @@ public CompletionStage<UnmanagedTransaction> beginTransactionAsync(
164164
return newTransactionStage;
165165
}
166166

167+
// Private API
168+
public CompletionStage<Void> resetAsync()
169+
{
170+
return existingTransactionOrNull()
171+
.thenAccept( tx ->
172+
{
173+
if ( tx != null )
174+
{
175+
tx.markTerminated( null );
176+
}
177+
} )
178+
.thenCompose( ignore -> connectionStage )
179+
.thenCompose( connection ->
180+
{
181+
if ( connection != null )
182+
{
183+
// there exists an active connection, send a RESET message over it
184+
return connection.reset();
185+
}
186+
return completedWithNull();
187+
} );
188+
}
189+
167190
public RetryLogic retryLogic() {
168191
return retryLogic;
169192
}

driver/src/main/java/org/neo4j/driver/internal/reactive/InternalRxSession.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@ public Bookmark lastBookmark() {
129129
return InternalBookmark.from(session.lastBookmarks());
130130
}
131131

132+
public Publisher<Void> reset()
133+
{
134+
return createEmptyPublisher( session::resetAsync );
135+
}
136+
132137
@Override
133138
public <T> Publisher<T> close() {
134139
return doClose();

0 commit comments

Comments
 (0)