Associate application classloader to auto-configured Hazelcast instance
Closes gh-24836
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -135,6 +135,18 @@ class HazelcastAutoConfigurationClientTests {
|
||||
.extracting(HazelcastInstance::getName).isEqualTo("spring-boot"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void autoConfiguredClientConfigUsesApplicationClassLoader() {
|
||||
this.contextRunner.withPropertyValues("spring.hazelcast.config=org/springframework/boot/autoconfigure/"
|
||||
+ "hazelcast/hazelcast-client-specific.xml").run((context) -> {
|
||||
HazelcastInstance hazelcast = context.getBean(HazelcastInstance.class);
|
||||
assertThat(hazelcast).isInstanceOf(HazelcastClientProxy.class);
|
||||
ClientConfig clientConfig = ((HazelcastClientProxy) hazelcast).getClientConfig();
|
||||
assertThat(clientConfig.getClassLoader())
|
||||
.isSameAs(context.getSourceApplicationContext().getClassLoader());
|
||||
});
|
||||
}
|
||||
|
||||
private ContextConsumer<AssertableApplicationContext> assertSpecificHazelcastClient(String label) {
|
||||
return (context) -> assertThat(context).getBean(HazelcastInstance.class).isInstanceOf(HazelcastInstance.class)
|
||||
.has(labelEqualTo(label));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -156,6 +156,14 @@ class HazelcastAutoConfigurationServerTests {
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void autoConfiguredConfigUsesApplicationClassLoader() {
|
||||
this.contextRunner.run((context) -> {
|
||||
Config config = context.getBean(HazelcastInstance.class).getConfig();
|
||||
assertThat(config.getClassLoader()).isSameAs(context.getSourceApplicationContext().getClassLoader());
|
||||
});
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
static class HazelcastConfigWithName {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user