`NullPointerException` at `SingleHostConnectionFunction#getCredentials` when configuration password is `null`
janainamendonca opened this issue · comments
Janaina Mendonca Lima commented
Bug Report
This is a regression from #613
Versions
- Driver: 1.0.3.RELEASE
- Database: CockroachDB
- Java: 21
- OS: macOS 14.1.2
Current Behavior
The PostgresqlConnectionConfiguration.Builder allows to build a configuration where the password field is null (instead of an empty publisher), it blows up when SingleHostConnectionFunction#getCredentials is called as it tries to create a Mono with null value.
Stack trace
Caused by: java.lang.NullPointerException: publisher
at java.base/java.util.Objects.requireNonNull(Objects.java:259)
at reactor.core.publisher.MonoFromPublisher.<init>(MonoFromPublisher.java:44)
at reactor.core.publisher.Mono.wrap(Mono.java:5383)
at reactor.core.publisher.Mono.from(Mono.java:507)
at io.r2dbc.postgresql.SingleHostConnectionFunction.getCredentials(SingleHostConnectionFunction.java:72)
at io.r2dbc.postgresql.SingleHostConnectionFunction.lambda$connect$2(SingleHostConnectionFunction.java:48)
at reactor.core.publisher.MonoDelayUntil$DelayUntilCoordinator.subscribeNextTrigger(MonoDelayUntil.java:293)
... 29 common frames omitted
Expected behavior/code
To not fail if a password is not set to the builder given that the field used to be nullable and the change from #613 changed the behaviour making it not compatible with existing code from SpringBoot.
Possible Solution
The builder could assign a default value (Mono.empty()
) to the password field