Removed the jdk11 classloader workaround; fixes gh-1193

This commit is contained in:
Marcin Grzejszczak
2019-01-25 13:07:11 +01:00
parent 0bc500ee78
commit 8941ed8e2d
3 changed files with 15 additions and 26 deletions

View File

@@ -21,7 +21,6 @@ import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.function.Function;
import java.util.function.Supplier;
import org.aopalliance.aop.Advice;
@@ -181,14 +180,6 @@ class ExecutorBeanPostProcessor implements BeanPostProcessor {
factory.setProxyTargetClass(cglibProxy);
factory.addAdvice(advice);
factory.setTarget(bean);
if (JavaVersion.current().isJava11Compatible()) {
if (log.isDebugEnabled()) {
log.debug("Creating an additional ClassLoader for JDK11");
}
factory.setBeanClassLoader(new ClassLoader(this.getClass().getClassLoader()) {
});
}
return getObject(factory);
}

View File

@@ -58,7 +58,8 @@ import org.springframework.util.Assert;
* @deprecated
*/
@Configuration
@ConditionalOnProperty(value = { "spring.sleuth.enabled", "spring.zipkin.enabled" }, matchIfMissing = true)
@ConditionalOnProperty(value = { "spring.sleuth.enabled",
"spring.zipkin.enabled" }, matchIfMissing = true)
@AutoConfigureBefore(ZipkinAutoConfiguration.class)
@Deprecated
public class ZipkinBackwardsCompatibilityAutoConfiguration {

View File

@@ -35,8 +35,7 @@ public class ZipkinBackwardsCompatibilityAutoConfigurationTests {
private ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(
ZipkinBackwardsCompatibilityAutoConfiguration.class,
ZipkinAutoConfiguration.class,
TraceAutoConfiguration.class));
ZipkinAutoConfiguration.class, TraceAutoConfiguration.class));
@Test
public void shouldLoadBeans() {
@@ -50,26 +49,24 @@ public class ZipkinBackwardsCompatibilityAutoConfigurationTests {
@Test
public void shouldNotLoadBackwardsCompatibilityConfigWhenZipkinDisabled() {
this.contextRunner
.withPropertyValues("spring.zipkin.enabled=false")
this.contextRunner.withPropertyValues("spring.zipkin.enabled=false")
.run(context -> {
assertThat(context.getBeansOfType(ZipkinProperties.class)).isEmpty();
assertThat(context.getBeansOfType(BytesEncoder.class)).isEmpty();
assertThat(context.getBean(ReporterMetrics.class)).isNotNull(); // TraceAutoConfiguration
assertThat(context.getBean(Reporter.class)).isNotNull(); // noOpSpanReporter
});
assertThat(context.getBeansOfType(ZipkinProperties.class)).isEmpty();
assertThat(context.getBeansOfType(BytesEncoder.class)).isEmpty();
assertThat(context.getBean(ReporterMetrics.class)).isNotNull(); // TraceAutoConfiguration
assertThat(context.getBean(Reporter.class)).isNotNull(); // noOpSpanReporter
});
}
@Test
public void shouldNotLoadBackwardsCompatibilityConfigWhenSleuthDisabled() {
this.contextRunner
.withPropertyValues("spring.sleuth.enabled=false")
this.contextRunner.withPropertyValues("spring.sleuth.enabled=false")
.run(context -> {
assertThat(context.getBeansOfType(ZipkinProperties.class)).isEmpty();
assertThat(context.getBeansOfType(BytesEncoder.class)).isEmpty();
assertThat(context.getBeansOfType(ReporterMetrics.class)).isEmpty();
assertThat(context.getBeansOfType(Reporter.class)).isEmpty();
});
assertThat(context.getBeansOfType(ZipkinProperties.class)).isEmpty();
assertThat(context.getBeansOfType(BytesEncoder.class)).isEmpty();
assertThat(context.getBeansOfType(ReporterMetrics.class)).isEmpty();
assertThat(context.getBeansOfType(Reporter.class)).isEmpty();
});
}
}