Skip to content

Commit f2fdd2e

Browse files
committed
Restore Session.reset as a private API
This reverts commit 33447f5.
1 parent fa6e4f8 commit f2fdd2e

File tree

13 files changed

+1030
-0
lines changed

13 files changed

+1030
-0
lines changed

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

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

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

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

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
*/
1919
package org.neo4j.driver.internal.reactive;
2020

21+
import static org.neo4j.driver.internal.reactive.RxUtils.createEmptyPublisher;
22+
2123
import java.util.Map;
2224
import java.util.concurrent.CompletableFuture;
2325
import org.neo4j.driver.AccessMode;
@@ -129,6 +131,10 @@ public Bookmark lastBookmark() {
129131
return InternalBookmark.from(session.lastBookmarks());
130132
}
131133

134+
public Publisher<Void> reset() {
135+
return createEmptyPublisher(session::resetAsync);
136+
}
137+
132138
@Override
133139
public <T> Publisher<T> close() {
134140
return doClose();

0 commit comments

Comments
 (0)