pgjdbc / r2dbc-postgresql

Postgresql R2DBC Driver
https://r2dbc.io
Apache License 2.0
1.01k stars 177 forks source link

`NullPointerException` at `SingleHostConnectionFunction#getCredentials` when configuration password is `null` #622

Closed janainamendonca closed 10 months ago

janainamendonca commented 10 months ago

Bug Report

This is a regression from #613

Versions

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.(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