Skip to content
This repository was archived by the owner on Jul 6, 2023. It is now read-only.

Commit fa569cb

Browse files
committed
Keep bookmark when switching database
1 parent 547254b commit fa569cb

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

cypher-shell/src/main/java/org/neo4j/shell/state/BoltStateHandler.java

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,26 +55,20 @@ public void setActiveDatabase(String databaseName) throws CommandException
5555
}
5656
String previousDatabaseName = activeDatabaseNameAsSetByUser;
5757
activeDatabaseNameAsSetByUser = databaseName;
58-
try
59-
{
60-
if ( isConnected() )
61-
{
62-
reconnect( false );
58+
try {
59+
if (isConnected()) {
60+
reconnect(true);
6361
}
6462
}
65-
catch ( ClientException e )
66-
{
67-
if ( isInteractive )
68-
{
63+
catch (ClientException e) {
64+
if (isInteractive) {
6965
// We want to try to connect to the previous database
7066
activeDatabaseNameAsSetByUser = previousDatabaseName;
71-
try
72-
{
73-
reconnect( false );
67+
try {
68+
reconnect(true);
7469
}
75-
catch ( ClientException e2 )
76-
{
77-
e.addSuppressed( e2 );
70+
catch (ClientException e2) {
71+
e.addSuppressed(e2);
7872
}
7973
}
8074
throw e;
@@ -182,7 +176,7 @@ private void reconnect(boolean keepBookmark) {
182176
builder.withBookmarks(systemBookmark);
183177
}
184178

185-
session = driver.session( builder.build() );
179+
session = driver.session(builder.build());
186180

187181
String query = activeDatabaseNameAsSetByUser.compareToIgnoreCase(SYSTEM_DB_NAME) == 0 ? "SHOW DEFAULT DATABASE" : "RETURN 1";
188182

0 commit comments

Comments
 (0)