Skip to content

NPE when properties are not defined for StreamsBuilderFactoryBean #4434

@jad837

Description

@jad837

In what version(s) of Spring for Apache Kafka are you seeing this issue?

For 3.3.15 and 4.0.0+

Describe the bug
Due to addition of .clone() In case of Empty properties in StreamsBuilderFactoryBean

Cannot invoke "java.util.Properties.clone()" because "this.properties" is null
java.lang.NullPointerException: Cannot invoke "java.util.Properties.clone()" because "this.properties" is null
	at org.springframework.kafka.config.StreamsBuilderFactoryBean.getStreamsConfiguration(StreamsBuilderFactoryBean.java:171)
	at org.springframework.kafka.streams.KafkaStreamsInteractiveQueryService.getCurrentKafkaStreamsApplicationHostInfo(KafkaStreamsInteractiveQueryService.java:117)
	at com.example.demo.KafkaStreamsConfigIntegrationTest.currentHostInfoWithNoProperties(KafkaStreamsConfigIntegrationTest.java:184)

To Reproduce
Test case to test behaviour.

    @Test
    void currentHostInfoWithNoProperties() {
        StreamsBuilderFactoryBean sbfb = new StreamsBuilderFactoryBean();
        sbfb.setAutoStartup(false);
        KafkaStreamsInteractiveQueryService iqs = new KafkaStreamsInteractiveQueryService(sbfb);
        HostInfo currentKafkaStreamsApplicationHostInfo = iqs.getCurrentKafkaStreamsApplicationHostInfo();
        assertThat(currentKafkaStreamsApplicationHostInfo).isNull();
    }

Expected behavior

Properties should be returned as Empty and no null pointer exception is shown. When calling StreamsBuilderFactoryBean.getStreamsConfiguration()

Reports that include a sample will take priority over reports that do not.
At times, we may require a sample, so it is good to try and include a sample up front.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions