Skip to content

SqsAutoConfiguration#configureProperties NPEs/throws when listener.* properties are left unset (regression from 3.x's alwaysApplyingWhenNonNull()) #1705

Closed

Description

@pasaroll

Type: Bug

Component: SQS

Describe the bug

SqsAutoConfiguration.configureProperties() maps SqsProperties.Listener's
maxConcurrentMessages, maxMessagesPerPoll, pollTimeout, maxDelayBetweenPolls,
and autoStartup unconditionally:

private void configureProperties(SqsContainerOptionsBuilder options) {
    PropertyMapper mapper = PropertyMapper.get();
    mapper.from(this.sqsProperties.getQueueNotFoundStrategy()).to(options::queueNotFoundStrategy);
    mapper.from(this.sqsProperties.getListener().getMaxConcurrentMessages()).to(options::maxConcurrentMessages);
    ...

All five Listener fields are @Nullable with no default, so an application that doesn't
explicitly set any of them (reasonable, since they all have sensible built-in defaults in
AbstractContainerOptions.Builder) gets a crash on every context startup:

  • a NullPointerException from unboxing null into the primitive int/boolean setters
    (maxConcurrentMessages, maxMessagesPerPoll, autoStartup), or
  • an IllegalArgumentException from the Assert.notNull guards inside
    AbstractContainerOptions.Builder (pollTimeout, maxDelayBetweenPolls)

-- whichever field the mapper reaches first.

This is a regression from 3.4.2, whose equivalent method guarded the whole block:

private void configureProperties(SqsContainerOptionsBuilder options) {
    PropertyMapper mapper = PropertyMapper.get().alwaysApplyingWhenNonNull();
    ...

That .alwaysApplyingWhenNonNull() call is missing in every 4.x release checked directly
against the Maven Central sources jars: 4.0.0, 4.0.1, 4.0.2, 4.1.0, 4.1.1 (latest).

Observed stack trace (with spring.cloud.aws.sqs.queue-not-found-strategy set, everything
else left at its default):

Caused by: java.lang.NullPointerException
    at org.springframework.boot.context.properties.PropertyMapper$Source.to(PropertyMapper.java:294)
    at io.awspring.cloud.autoconfigure.sqs.SqsAutoConfiguration.configureProperties(SqsAutoConfiguration.java:214)
    at io.awspring.cloud.sqs.config.AbstractMessageListenerContainerFactory.configure(AbstractMessageListenerContainerFactory.java:174)
    at io.awspring.cloud.autoconfigure.sqs.SqsAutoConfiguration.defaultSqsListenerContainerFactory(SqsAutoConfiguration.java:192)

Expected: unset listener properties should fall back to AbstractContainerOptions.Builder's
own defaults, as they did in 3.x, rather than crashing context startup.

Suggested fix: restore PropertyMapper.get().alwaysApplyingWhenNonNull() (or add
.whenNonNull() per mapping) in SqsAutoConfiguration.configureProperties().

Versions:

  • spring-cloud-aws-dependencies: 4.1.1 (also present in 4.0.0-4.1.0)
  • Spring Boot: 3.5.16
  • Java: 21 / 25

Sample

Minimal Spring Boot app that reproduces this on context startup. Only dependency beyond
spring-boot-starter is spring-cloud-aws-starter-sqs (version managed by the
spring-cloud-aws-dependencies:4.1.1 BOM); no spring.cloud.aws.sqs.listener.*
properties are set.

pom.xml (relevant sections):

<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>io.awspring.cloud</groupId>
      <artifactId>spring-cloud-aws-dependencies</artifactId>
      <version>4.1.1</version>
      <type>pom</type>
      <scope>import</scope>
    </dependency>
  </dependencies>
</dependencyManagement>
<dependencies>
  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter</artifactId>
  </dependency>
  <dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
  </dependency>
  <dependency>
    <groupId>io.awspring.cloud</groupId>
    <artifactId>spring-cloud-aws-starter-sqs</artifactId>
  </dependency>
</dependencies>

application.properties:

spring.cloud.aws.region.static=us-east-1
spring.cloud.aws.sqs.queue-not-found-strategy=fail

Test (the mocked SqsAsyncClient bean only exists to isolate this from real network/event-loop
setup, which is unrelated to the bug):

@SpringBootTest
class ReproApplicationTests {

    @TestConfiguration
    static class MockSqsClientConfig {
        @Bean
        SqsAsyncClient sqsAsyncClient() {
            return mock(SqsAsyncClient.class);
        }
    }

    @Test
    void contextLoads() {
    }
}

Running this test throws the NullPointerException above immediately on context startup.

Activity

  1. gibkim commented on Oct 3, 2026

    @gibkim

    I think this comes from running 4.1.1 on Spring Boot 3.5. The README says 3.4.x is the last Spring Cloud AWS line compatible with Boot 3.5.x, and 4.x targets Boot 4.

    In Boot 4, PropertyMapper skips null sources by default (class Javadoc: "By default null values and any NullPointerException thrown from the supplier are filtered and will not be applied to consumers"; Source.always(), added in 4.0.0, opts out). That is why alwaysApplyingWhenNonNull() is no longer needed in 4.x. On Boot 3.5 the same code maps the null values and fails.

    I ran the reproducer from the description (mocked SqsAsyncClient, only queue-not-found-strategy set, no listener.* properties):

    Spring Boot Spring Cloud AWS Result
    4.0.2 4.1.1 context starts, SqsMessageListenerContainerFactory created
    3.5.16 4.1.1 NullPointerException at PropertyMapper.java:294, as reported
    3.5.16 3.4.2 context starts

    So on a supported combination this doesn't fail. If 4.x is meant to work on Boot 3.5 too, the fix suggested above would be needed; otherwise upgrading to Boot 4 or staying on 3.4.x avoids it.

  2. MatejNedic commented on Oct 14, 2026

    @MatejNedic
    Member

    Hey @pasaroll ,

    Spring Boot 3.5.16 shouldn't be used with Spring Cloud AWS 4.1.1.

    Spring Cloud AWS 4.x.x is only compatible with Spring Boot version 4.x.x and above. Please check Spring Cloud AWS version support.

    Please use Spring Cloud AWS version 3.4.2 with Spring Boot 3.5.16.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions