Skip to content

NPE in RabbitProperties when user is given, but password not #33752

@mhalbritter

Description

@mhalbritter
private final RabbitProperties properties = new RabbitProperties();

	@Test
	void determineUsernameWithoutPassword() {
		this.properties.setAddresses("user@rabbit1.example.com:1234/alpha");
		assertThat(this.properties.determineUsername()).isEqualTo("user");
		assertThat(this.properties.determinePassword()).isEqualTo("guest");
	}

This throws an NPE:

java.lang.NullPointerException: Cannot load from object array because "split" is null

	at org.springframework.boot.autoconfigure.amqp.RabbitProperties$Address.parseUsernameAndPassword(RabbitProperties.java:1135)
	at org.springframework.boot.autoconfigure.amqp.RabbitProperties$Address.<init>(RabbitProperties.java:1112)
	at org.springframework.boot.autoconfigure.amqp.RabbitProperties.parseAddresses(RabbitProperties.java:223)
	at org.springframework.boot.autoconfigure.amqp.RabbitProperties.setAddresses(RabbitProperties.java:217)
	at org.springframework.boot.autoconfigure.amqp.RabbitPropertiesTests.determineUsernameWithoutPassword(RabbitPropertiesTests.java:233)
...

The code expects that username and password is given, only username doesn't work.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions