Skip to content

Commit 41deba0

Browse files
committed
Add temporary internal only reset capability
This is required for an internal dependency and must not be used as a public API as it temporary only. This reverts commit 33447f5.
1 parent b7ce3ee commit 41deba0

File tree

4 files changed

+649
-0
lines changed

4 files changed

+649
-0
lines changed

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

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

143+
// Temporary private API
144+
@Deprecated
145+
public void reset() {
146+
Futures.blockingGet(
147+
session.resetAsync(),
148+
() -> terminateConnectionOnThreadInterrupt("Thread interrupted while resetting the session"));
149+
}
150+
143151
private <T> T transaction(
144152
AccessMode mode, @SuppressWarnings("deprecation") TransactionWork<T> work, TransactionConfig config) {
145153
// 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: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,23 @@ public CompletionStage<UnmanagedTransaction> beginTransactionAsync(
164164
return newTransactionStage;
165165
}
166166

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

0 commit comments

Comments
 (0)