Skip to content

Commit 5e8812a

Browse files
committed
Merge branch '3.4.x'
Closes gh-44969
2 parents 25ea590 + b1fb36b commit 5e8812a

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/integration/IntegrationPropertiesEnvironmentPostProcessorTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import java.util.Map;
2626
import java.util.function.Consumer;
2727

28-
import io.lettuce.core.dynamic.support.ReflectionUtils;
2928
import org.junit.jupiter.api.Test;
3029
import org.junit.jupiter.params.ParameterizedTest;
3130
import org.junit.jupiter.params.provider.MethodSource;
@@ -48,6 +47,7 @@
4847
import org.springframework.mock.env.MockEnvironment;
4948
import org.springframework.test.util.ReflectionTestUtils;
5049
import org.springframework.util.ClassUtils;
50+
import org.springframework.util.ReflectionUtils;
5151

5252
import static org.assertj.core.api.Assertions.assertThat;
5353
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;

spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/intTest/java/org/springframework/boot/context/embedded/EmbeddedServerContainerInvocationContextProvider.java

+14-5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import java.io.File;
2020
import java.io.IOException;
21+
import java.lang.reflect.Constructor;
2122
import java.net.URI;
2223
import java.nio.file.Files;
2324
import java.nio.file.Path;
@@ -41,11 +42,12 @@
4142
import org.junit.jupiter.api.extension.ParameterResolver;
4243
import org.junit.jupiter.api.extension.TestTemplateInvocationContext;
4344
import org.junit.jupiter.api.extension.TestTemplateInvocationContextProvider;
44-
import org.junit.platform.commons.util.ReflectionUtils;
4545

46+
import org.springframework.beans.BeanUtils;
4647
import org.springframework.boot.testsupport.BuildOutput;
4748
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
4849
import org.springframework.util.FileSystemUtils;
50+
import org.springframework.util.ReflectionUtils;
4951
import org.springframework.util.StringUtils;
5052
import org.springframework.web.client.NoOpResponseErrorHandler;
5153
import org.springframework.web.client.RestTemplate;
@@ -119,10 +121,17 @@ private AbstractApplicationLauncher getAbstractApplicationLauncher(Application a
119121
if (cachedLauncher != null) {
120122
return cachedLauncher;
121123
}
122-
AbstractApplicationLauncher launcher = ReflectionUtils.newInstance(launcherClass, application,
123-
new File(buildOutput.getRootLocation(), "app-launcher-" + UUID.randomUUID()));
124-
this.launcherCache.put(cacheKey, launcher);
125-
return launcher;
124+
try {
125+
Constructor<? extends AbstractApplicationLauncher> constructor = ReflectionUtils
126+
.accessibleConstructor(launcherClass, Application.class, File.class);
127+
AbstractApplicationLauncher launcher = BeanUtils.instantiateClass(constructor, application,
128+
new File(buildOutput.getRootLocation(), "app-launcher-" + UUID.randomUUID()));
129+
this.launcherCache.put(cacheKey, launcher);
130+
return launcher;
131+
}
132+
catch (NoSuchMethodException ex) {
133+
throw new IllegalStateException("Launcher class %s does not have an (Application, File) constructor");
134+
}
126135
}
127136

128137
private Application getApplication(EmbeddedServletContainerTest annotation, String container) {

src/checkstyle/checkstyle.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<property name="illegalPkgs"
1717
value="^sun.*, ^org\.apache\.commons\.(?!compress|dbcp2|logging|pool2).*, ^com\.datastax\.oss\.driver\.shaded.*, ^com\.google\.common.*, ^io\.micrometer\.core\.lang.*, ^io\.micrometer\.shaded.*, ^org\.jetbrains\.annotations.*, ^org\.testcontainers\.shaded.*" />
1818
<property name="illegalClasses"
19-
value="^com\.hazelcast\.util\.Base64, ^org\.junit\.rules\.ExpectedException, ^org\.mockito\.InjectMocks, ^org\.slf4j\.LoggerFactory, ^org.springframework.context.annotation.ScannedGenericBeanDefinition, ^reactor\.core\.support\.Assert"/>
19+
value="^com\.hazelcast\.util\.Base64, ^org\.junit\.rules\.ExpectedException, ^org\.mockito\.InjectMocks, ^org\.slf4j\.LoggerFactory, ^org.springframework.context.annotation.ScannedGenericBeanDefinition, ^reactor\.core\.support\.Assert, ^(?!org\.springframework\.util\.).*ReflectionUtils"/>
2020
</module>
2121
<module
2222
name="com.puppycrawl.tools.checkstyle.checks.imports.IllegalImportCheck">

0 commit comments

Comments
 (0)