Skip to content

Commit 81c0bfb

Browse files
committed
Add nullability annotations to module/spring-boot-hazelcast
See gh-46587
1 parent 363ddb5 commit 81c0bfb

File tree

8 files changed

+34
-11
lines changed

8 files changed

+34
-11
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@
2222

2323
import com.hazelcast.client.config.ClientConfigRecognizer;
2424
import com.hazelcast.config.ConfigStream;
25+
import org.jspecify.annotations.Nullable;
2526

2627
import org.springframework.boot.autoconfigure.condition.ConditionMessage.Builder;
2728
import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
2829
import org.springframework.context.annotation.ConditionContext;
2930
import org.springframework.core.io.Resource;
3031
import org.springframework.core.type.AnnotatedTypeMetadata;
32+
import org.springframework.util.Assert;
3133

3234
/**
3335
* {@link HazelcastConfigResourceCondition} that checks if the
@@ -56,8 +58,10 @@ public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeM
5658

5759
static class HazelcastClientValidation {
5860

59-
static ConditionOutcome clientConfigOutcome(ConditionContext context, String propertyName, Builder builder) {
61+
static @Nullable ConditionOutcome clientConfigOutcome(ConditionContext context, String propertyName,
62+
Builder builder) {
6063
String resourcePath = context.getEnvironment().getProperty(propertyName);
64+
Assert.state(resourcePath != null, "'resourcePath' must not be null");
6165
Resource resource = context.getResourceLoader().getResource(resourcePath);
6266
if (!resource.exists()) {
6367
return ConditionOutcome.noMatch(builder.because("Hazelcast configuration does not exist"));

module/spring-boot-hazelcast/src/main/java/org/springframework/boot/hazelcast/autoconfigure/HazelcastProperties.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package org.springframework.boot.hazelcast.autoconfigure;
1818

19+
import org.jspecify.annotations.Nullable;
20+
1921
import org.springframework.boot.context.properties.ConfigurationProperties;
2022
import org.springframework.core.io.Resource;
2123
import org.springframework.util.Assert;
@@ -32,13 +34,13 @@ public class HazelcastProperties {
3234
/**
3335
* The location of the configuration file to use to initialize Hazelcast.
3436
*/
35-
private Resource config;
37+
private @Nullable Resource config;
3638

37-
public Resource getConfig() {
39+
public @Nullable Resource getConfig() {
3840
return this.config;
3941
}
4042

41-
public void setConfig(Resource config) {
43+
public void setConfig(@Nullable Resource config) {
4244
this.config = config;
4345
}
4446

@@ -48,13 +50,13 @@ public void setConfig(Resource config) {
4850
* @throws IllegalArgumentException if the config attribute is set to an unknown
4951
* location
5052
*/
51-
public Resource resolveConfigLocation() {
52-
if (this.config == null) {
53+
public @Nullable Resource resolveConfigLocation() {
54+
Resource config = this.config;
55+
if (config == null) {
5356
return null;
5457
}
55-
Assert.state(this.config.exists(),
56-
() -> "Hazelcast configuration does not exist '" + this.config.getDescription() + "'");
57-
return this.config;
58+
Assert.state(config.exists(), () -> "Hazelcast configuration does not exist '" + config.getDescription() + "'");
59+
return config;
5860
}
5961

6062
}

module/spring-boot-hazelcast/src/main/java/org/springframework/boot/hazelcast/autoconfigure/health/package-info.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,7 @@
1717
/**
1818
* Auto-configuration for Hazelcast health.
1919
*/
20+
@NullMarked
2021
package org.springframework.boot.hazelcast.autoconfigure.health;
22+
23+
import org.jspecify.annotations.NullMarked;

module/spring-boot-hazelcast/src/main/java/org/springframework/boot/hazelcast/autoconfigure/package-info.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,7 @@
1717
/**
1818
* Auto-configuration for Hazelcast.
1919
*/
20+
@NullMarked
2021
package org.springframework.boot.hazelcast.autoconfigure;
22+
23+
import org.jspecify.annotations.NullMarked;

module/spring-boot-hazelcast/src/main/java/org/springframework/boot/hazelcast/docker/compose/HazelcastEnvironment.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,22 @@
1818

1919
import java.util.Map;
2020

21+
import org.jspecify.annotations.Nullable;
22+
2123
/**
2224
* Hazelcast environment details.
2325
*
2426
* @author Dmytro Nosan
2527
*/
2628
class HazelcastEnvironment {
2729

28-
private final String clusterName;
30+
private final @Nullable String clusterName;
2931

3032
HazelcastEnvironment(Map<String, String> env) {
3133
this.clusterName = env.get("HZ_CLUSTERNAME");
3234
}
3335

34-
String getClusterName() {
36+
@Nullable String getClusterName() {
3537
return this.clusterName;
3638
}
3739

module/spring-boot-hazelcast/src/main/java/org/springframework/boot/hazelcast/docker/compose/package-info.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,7 @@
1717
/**
1818
* Support for Docker Compose Hazelcast service connections.
1919
*/
20+
@NullMarked
2021
package org.springframework.boot.hazelcast.docker.compose;
22+
23+
import org.jspecify.annotations.NullMarked;

module/spring-boot-hazelcast/src/main/java/org/springframework/boot/hazelcast/health/package-info.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,7 @@
1717
/**
1818
* Health integration for Hazelcast.
1919
*/
20+
@NullMarked
2021
package org.springframework.boot.hazelcast.health;
22+
23+
import org.jspecify.annotations.NullMarked;

module/spring-boot-hazelcast/src/main/java/org/springframework/boot/hazelcast/testcontainers/package-info.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,7 @@
1717
/**
1818
* Support for testcontainers Hazelcast service connections.
1919
*/
20+
@NullMarked
2021
package org.springframework.boot.hazelcast.testcontainers;
22+
23+
import org.jspecify.annotations.NullMarked;

0 commit comments

Comments
 (0)