Skip to content

Deprecated EnvironmentPostProcessor does not resolve arguments #48047

@ciscoo

Description

@ciscoo

#47272 added back the previous EnvironmentPostProcessor in deprecated form, but the implementation (3a9ab15) seems incomplete.

The following fails:

import org.junit.jupiter.api.Test;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.bootstrap.ConfigurableBootstrapContext;
import org.springframework.boot.env.EnvironmentPostProcessor;
import org.springframework.boot.logging.DeferredLogFactory;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.util.Assert;

@SpringBootTest
class DemoApplicationTests {

	@Test
	void contextLoads() {
	}

    static class DeprecatedEnvironmentPostProcessor implements EnvironmentPostProcessor {

        public DeprecatedEnvironmentPostProcessor(DeferredLogFactory logFactory, ConfigurableBootstrapContext bootstrapContext) {
            Assert.notNull(logFactory, "logFactory must not be null");
            Assert.notNull(bootstrapContext, "bootstrapContext must not be null");
        }

        @Override
        public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {

        }

    }

}

I had expected that the deprecated EnvironmentPostProcessor continue to work, but fails due to null constructor arguments.

Looks like the call to load the deprecated EnvironmentPostProcessor missed providing the ArgumentResolver as it does for the non-deprecated variant:

postProcessors.addAll(this.loader.load(EnvironmentPostProcessor.class, argumentResolver));

return this.loader.load(org.springframework.boot.env.EnvironmentPostProcessor.class);

Metadata

Metadata

Assignees

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