When updating Spring Boot to 3.2.1 from 3.1.8 one of our unit test fails when using a MockEnvironment with java.util.NoSuchElementException: No value bound. Have tested with all 3.2.* versions with same outcome. Reverting to 3.1.8 fixes the issue.

Simplified code to show the error:

Class Under Test:

public class TennisConfigHelper implements ConfigHelper {

    @Override
    public SubscriberFeedsConfig getSubscriberFeedsConfig(Environment environment) {
        return Binder.get(environment).bind("feeds", SubscriberFeedsConfig.class).get();
    }
}

Test:

void shouldGetSubscriberFeedsConfig() {
    MockEnvironment environment = new MockEnvironment()
        .withProperty("feeds.messageHelperClass", "TennisMessageHelper")
        .withProperty("feeds.configHelperClass", "TennisConfigHelper")

    SubscriberFeedsConfig subscriberFeedsConfig = helper.getSubscriberFeedsConfig(environment);

// various assertions
}

Comment From: wilkinsona

Thanks for the report. Can you please provide a complete example of the problem that we can run without modification or resorting to copy-paste? You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.

Comment From: mukham12

@wilkinsona,

I tried putting together the whole code using the info we have, but no luck – couldn't replicate the problem. I ran the test on both Spring Boot 3.1.8 and 3.2.1, and no exceptions were thrown. Unless the reporter has some specific setup I missed, it seems like a non-issue to me.

While we wait for the author's reply, here's the link to what I tried: https://github.com/mukham12/spring-boot-39320

Comment From: marksilcox

Took a bit of digging into the dependencies for the project this code is from, but finally found that when updating to 3.2 in some of the dependencies we had missed add compile options to the build.gradle as defined here:

tasks.withType(JavaCompile).configureEach {
    options.compilerArgs.add("-parameters")
}