Skip to content

Commit 57555d4

Browse files
committed
Ensure database is not null in explicit request
1 parent e945c2a commit 57555d4

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

driver/src/main/java/org/neo4j/driver/BookmarkSupplier.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public interface BookmarkSupplier {
2929
/**
3030
* Supplies a set of bookmarks for a given database.
3131
*
32-
* @param database the database name
32+
* @param database the database name, must not be {@code null}
3333
* @return the set of bookmarks, must not be {@code null}
3434
*/
3535
Set<Bookmark> getBookmarks(String database);

testkit-backend/src/main/java/neo4j/org/testkit/backend/messages/requests/TestkitBookmarkSupplier.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
*/
1919
package neo4j.org.testkit.backend.messages.requests;
2020

21+
import java.util.Objects;
2122
import java.util.Set;
2223
import java.util.concurrent.CompletionStage;
2324
import java.util.function.BiFunction;
24-
import java.util.function.Supplier;
2525
import java.util.stream.Collectors;
2626
import lombok.RequiredArgsConstructor;
2727
import neo4j.org.testkit.backend.TestkitState;
@@ -37,20 +37,21 @@ class TestkitBookmarkSupplier implements BookmarkSupplier {
3737

3838
@Override
3939
public Set<Bookmark> getBookmarks(String database) {
40-
return getBookmarksFromTestkit(() -> database);
40+
Objects.requireNonNull(database, "database may not be null");
41+
return getBookmarksFromTestkit(database);
4142
}
4243

4344
@Override
4445
public Set<Bookmark> getAllBookmarks() {
4546
return getBookmarksFromTestkit(null);
4647
}
4748

48-
private Set<Bookmark> getBookmarksFromTestkit(Supplier<String> databaseSupplier) {
49+
private Set<Bookmark> getBookmarksFromTestkit(String database) {
4950
var callbackId = testkitState.newId();
5051
var bodyBuilder =
5152
BookmarksSupplierRequest.BookmarksSupplierRequestBody.builder().id(callbackId);
52-
if (databaseSupplier != null) {
53-
bodyBuilder = bodyBuilder.database(databaseSupplier.get());
53+
if (database != null) {
54+
bodyBuilder = bodyBuilder.database(database);
5455
}
5556
var callback =
5657
BookmarksSupplierRequest.builder().data(bodyBuilder.build()).build();

0 commit comments

Comments
 (0)