Sets the child class loader to parent class loader.

This prevents odd behavior in jdk 11 +

Fixes https://github.com/spring-cloud/spring-cloud-netflix/issues/3101
This commit is contained in:
Spencer Gibb
2019-02-14 15:54:27 -05:00
parent a7c344f83f
commit b38ce54410
2 changed files with 11 additions and 0 deletions

View File

@@ -19,6 +19,7 @@ package org.springframework.cloud.context.named;
import java.util.Arrays;
import java.util.Map;
import org.assertj.core.api.Assertions;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
@@ -65,6 +66,13 @@ public class NamedContextFactoryTests {
AnnotationConfigApplicationContext fooContext = factory.getContext("foo");
AnnotationConfigApplicationContext barContext = factory.getContext("bar");
then(fooContext.getClassLoader())
.as("foo context classloader does not match parent")
.isSameAs(parent.getClassLoader());
Assertions.assertThat(fooContext).hasFieldOrPropertyWithValue("customClassLoader",
true);
factory.destroy();
then(fooContext.isActive()).as("foo context wasn't closed").isFalse();