Skip to content

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

Closed

Description

@janainamendonca

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

Activity

  1. added this to the 1.0.4.RELEASE milestone on Dec 28, 2023
  2. changed the title [-]NullPointerException at SingleHostConnectionFunction#getCredentials when configuration password is null (regression from #613)[/-] [+]`NullPointerException` at `SingleHostConnectionFunction#getCredentials` when configuration password is `null`[/+] on Dec 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: regressionA regression from a previous release

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions