Skip to content

Commit 2fb257a

Browse files
committed
Merge branch '2.6.x' into 2.7.x
Closes gh-32247
2 parents 74a88cd + 1f535a6 commit 2fb257a

File tree

10 files changed

+85
-11
lines changed

10 files changed

+85
-11
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastClientConfigAvailableCondition.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -39,7 +39,8 @@ class HazelcastClientConfigAvailableCondition extends HazelcastConfigResourceCon
3939

4040
HazelcastClientConfigAvailableCondition() {
4141
super(HazelcastClientConfiguration.CONFIG_SYSTEM_PROPERTY, "file:./hazelcast-client.xml",
42-
"classpath:/hazelcast-client.xml", "file:./hazelcast-client.yaml", "classpath:/hazelcast-client.yaml");
42+
"classpath:/hazelcast-client.xml", "file:./hazelcast-client.yaml", "classpath:/hazelcast-client.yaml",
43+
"file:./hazelcast-client.yml", "classpath:/hazelcast-client.yml");
4344
}
4445

4546
@Override

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastClientConfiguration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2021 the original author or authors.
2+
* Copyright 2012-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -72,7 +72,7 @@ HazelcastInstance hazelcastInstance(HazelcastProperties properties, ResourceLoad
7272
private ClientConfig loadClientConfig(Resource configLocation) throws IOException {
7373
URL configUrl = configLocation.getURL();
7474
String configFileName = configUrl.getPath();
75-
if (configFileName.endsWith(".yaml")) {
75+
if (configFileName.endsWith(".yaml") || configFileName.endsWith(".yml")) {
7676
return new YamlClientConfigBuilder(configUrl).build();
7777
}
7878
return new XmlClientConfigBuilder(configUrl).build();

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastServerConfiguration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ private Config loadConfig(Resource configLocation) throws IOException {
9090

9191
private static Config loadConfig(URL configUrl) throws IOException {
9292
String configFileName = configUrl.getPath();
93-
if (configFileName.endsWith(".yaml")) {
93+
if (configFileName.endsWith(".yaml") || configFileName.endsWith(".yml")) {
9494
return new YamlConfigBuilder(configUrl).build();
9595
}
9696
return new XmlConfigBuilder(configUrl).build();
@@ -149,7 +149,7 @@ static class ConfigAvailableCondition extends HazelcastConfigResourceCondition {
149149

150150
ConfigAvailableCondition() {
151151
super(CONFIG_SYSTEM_PROPERTY, "file:./hazelcast.xml", "classpath:/hazelcast.xml", "file:./hazelcast.yaml",
152-
"classpath:/hazelcast.yaml");
152+
"classpath:/hazelcast.yaml", "file:./hazelcast.yml", "classpath:/hazelcast.yml");
153153
}
154154

155155
}

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastAutoConfigurationClientTests.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2021 the original author or authors.
2+
* Copyright 2012-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -81,6 +81,14 @@ void systemPropertyWithYaml() {
8181
.run(assertSpecificHazelcastClient("explicit-yaml"));
8282
}
8383

84+
@Test
85+
void systemPropertyWithYml() {
86+
this.contextRunner
87+
.withSystemProperties(HazelcastClientConfiguration.CONFIG_SYSTEM_PROPERTY
88+
+ "=classpath:org/springframework/boot/autoconfigure/hazelcast/hazelcast-client-specific.yml")
89+
.run(assertSpecificHazelcastClient("explicit-yml"));
90+
}
91+
8492
@Test
8593
void explicitConfigFileWithXml() {
8694
this.contextRunner.withPropertyValues("spring.hazelcast.config=org/springframework/boot/autoconfigure/"
@@ -95,6 +103,12 @@ void explicitConfigFileWithYaml() {
95103
.run(assertSpecificHazelcastClient("explicit-yaml"));
96104
}
97105

106+
@Test
107+
void explicitConfigFileWithYml() {
108+
this.contextRunner.withPropertyValues("spring.hazelcast.config=org/springframework/boot/autoconfigure/"
109+
+ "hazelcast/hazelcast-client-specific.yml").run(assertSpecificHazelcastClient("explicit-yml"));
110+
}
111+
98112
@Test
99113
void explicitConfigUrlWithXml() {
100114
this.contextRunner
@@ -111,6 +125,14 @@ void explicitConfigUrlWithYaml() {
111125
.run(assertSpecificHazelcastClient("explicit-yaml"));
112126
}
113127

128+
@Test
129+
void explicitConfigUrlWithYml() {
130+
this.contextRunner
131+
.withPropertyValues("spring.hazelcast.config=classpath:org/springframework/"
132+
+ "boot/autoconfigure/hazelcast/hazelcast-client-specific.yml")
133+
.run(assertSpecificHazelcastClient("explicit-yml"));
134+
}
135+
114136
@Test
115137
void unknownConfigFile() {
116138
this.contextRunner.withPropertyValues("spring.hazelcast.config=foo/bar/unknown.xml")

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastAutoConfigurationServerTests.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,17 @@ void systemPropertyWithYaml() {
8787
});
8888
}
8989

90+
@Test
91+
void systemPropertyWithYml() {
92+
this.contextRunner
93+
.withSystemProperties(HazelcastServerConfiguration.CONFIG_SYSTEM_PROPERTY
94+
+ "=classpath:org/springframework/boot/autoconfigure/hazelcast/hazelcast-specific.yml")
95+
.run((context) -> {
96+
Config config = context.getBean(HazelcastInstance.class).getConfig();
97+
assertThat(config.getMapConfigs().keySet()).containsOnly("foobar");
98+
});
99+
}
100+
90101
@Test
91102
void explicitConfigFileWithXml() {
92103
this.contextRunner
@@ -105,6 +116,15 @@ void explicitConfigFileWithYaml() {
105116
"org/springframework/boot/autoconfigure/hazelcast/hazelcast-specific.yaml"));
106117
}
107118

119+
@Test
120+
void explicitConfigFileWithYml() {
121+
this.contextRunner
122+
.withPropertyValues("spring.hazelcast.config=org/springframework/boot/autoconfigure/hazelcast/"
123+
+ "hazelcast-specific.yml")
124+
.run(assertSpecificHazelcastServer(
125+
"org/springframework/boot/autoconfigure/hazelcast/hazelcast-specific.yml"));
126+
}
127+
108128
@Test
109129
void explicitConfigUrlWithXml() {
110130
this.contextRunner
@@ -123,6 +143,15 @@ void explicitConfigUrlWithYaml() {
123143
"org/springframework/boot/autoconfigure/hazelcast/hazelcast-specific.yaml"));
124144
}
125145

146+
@Test
147+
void explicitConfigUrlWithYml() {
148+
this.contextRunner
149+
.withPropertyValues("spring.hazelcast.config=classpath:org/springframework/"
150+
+ "boot/autoconfigure/hazelcast/hazelcast-specific.yml")
151+
.run(assertSpecificHazelcastServer(
152+
"org/springframework/boot/autoconfigure/hazelcast/hazelcast-specific.yml"));
153+
}
154+
126155
private ContextConsumer<AssertableApplicationContext> assertSpecificHazelcastServer(String location) {
127156
return (context) -> {
128157
Config config = context.getBean(HazelcastInstance.class).getConfig();

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastAutoConfigurationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -45,7 +45,7 @@ class HazelcastAutoConfigurationTests {
4545
void defaultConfigFile() {
4646
// no hazelcast-client.xml and hazelcast.xml is present in root classpath
4747
// this also asserts that XML has priority over YAML
48-
// as both hazelcast.yaml and hazelcast.xml in test classpath.
48+
// as hazelcast.yaml, hazelcast.yml, and hazelcast.xml are available.
4949
this.contextRunner.run((context) -> {
5050
Config config = context.getBean(HazelcastInstance.class).getConfig();
5151
assertThat(config.getConfigurationUrl()).isEqualTo(new ClassPathResource("hazelcast.xml").getURL());
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
hazelcast:
2+
network:
3+
join:
4+
auto-detection:
5+
enabled: false
6+
multicast:
7+
enabled: false
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
hazelcast-client:
2+
client-labels:
3+
- explicit-yml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
hazelcast:
2+
network:
3+
join:
4+
auto-detection:
5+
enabled: false
6+
multicast:
7+
enabled: false
8+
9+
map:
10+
foobar:
11+
time-to-live-seconds: 3600
12+
max-idle-seconds: 600

spring-boot-project/spring-boot-docs/src/docs/asciidoc/io/hazelcast.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Spring Boot first attempts to create a client by checking the following configur
88
* A configuration file defined by the configprop:spring.hazelcast.config[] property.
99
* The presence of the `hazelcast.client.config` system property.
1010
* A `hazelcast-client.xml` in the working directory or at the root of the classpath.
11-
* A `hazelcast-client.yaml` in the working directory or at the root of the classpath.
11+
* A `hazelcast-client.yaml` (or `hazelcast-client.yml`) in the working directory or at the root of the classpath.
1212

1313
WARNING: Hazelcast 3 support is deprecated.
1414
If you still need to downgrade to Hazelcast 3, `hazelcast-client` should be added to the classpath to configure a client.
@@ -26,7 +26,7 @@ You could also specify the Hazelcast configuration file to use through configura
2626
config: "classpath:config/my-hazelcast.xml"
2727
----
2828

29-
Otherwise, Spring Boot tries to find the Hazelcast configuration from the default locations: `hazelcast.xml` in the working directory or at the root of the classpath, or a `.yaml` counterpart in the same locations.
29+
Otherwise, Spring Boot tries to find the Hazelcast configuration from the default locations: `hazelcast.xml` in the working directory or at the root of the classpath, or a `.yaml`/`.yml` counterpart in the same locations.
3030
We also check if the `hazelcast.config` system property is set.
3131
See the https://docs.hazelcast.org/docs/latest/manual/html-single/[Hazelcast documentation] for more details.
3232

0 commit comments

Comments
 (0)