Browse Source

Add nullability annotations to module/spring-boot-hazelcast

See gh-46587
pull/46651/head
Moritz Halbritter 5 months ago
parent
commit
81c0bfb048
  1. 6
      module/spring-boot-hazelcast/src/main/java/org/springframework/boot/hazelcast/autoconfigure/HazelcastClientConfigAvailableCondition.java
  2. 18
      module/spring-boot-hazelcast/src/main/java/org/springframework/boot/hazelcast/autoconfigure/HazelcastProperties.java
  3. 3
      module/spring-boot-hazelcast/src/main/java/org/springframework/boot/hazelcast/autoconfigure/health/package-info.java
  4. 3
      module/spring-boot-hazelcast/src/main/java/org/springframework/boot/hazelcast/autoconfigure/package-info.java
  5. 6
      module/spring-boot-hazelcast/src/main/java/org/springframework/boot/hazelcast/docker/compose/HazelcastEnvironment.java
  6. 3
      module/spring-boot-hazelcast/src/main/java/org/springframework/boot/hazelcast/docker/compose/package-info.java
  7. 3
      module/spring-boot-hazelcast/src/main/java/org/springframework/boot/hazelcast/health/package-info.java
  8. 3
      module/spring-boot-hazelcast/src/main/java/org/springframework/boot/hazelcast/testcontainers/package-info.java

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

@ -22,12 +22,14 @@ import java.net.URL; @@ -22,12 +22,14 @@ import java.net.URL;
import com.hazelcast.client.config.ClientConfigRecognizer;
import com.hazelcast.config.ConfigStream;
import org.jspecify.annotations.Nullable;
import org.springframework.boot.autoconfigure.condition.ConditionMessage.Builder;
import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.io.Resource;
import org.springframework.core.type.AnnotatedTypeMetadata;
import org.springframework.util.Assert;
/**
* {@link HazelcastConfigResourceCondition} that checks if the
@ -56,8 +58,10 @@ class HazelcastClientConfigAvailableCondition extends HazelcastConfigResourceCon @@ -56,8 +58,10 @@ class HazelcastClientConfigAvailableCondition extends HazelcastConfigResourceCon
static class HazelcastClientValidation {
static ConditionOutcome clientConfigOutcome(ConditionContext context, String propertyName, Builder builder) {
static @Nullable ConditionOutcome clientConfigOutcome(ConditionContext context, String propertyName,
Builder builder) {
String resourcePath = context.getEnvironment().getProperty(propertyName);
Assert.state(resourcePath != null, "'resourcePath' must not be null");
Resource resource = context.getResourceLoader().getResource(resourcePath);
if (!resource.exists()) {
return ConditionOutcome.noMatch(builder.because("Hazelcast configuration does not exist"));

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

@ -16,6 +16,8 @@ @@ -16,6 +16,8 @@
package org.springframework.boot.hazelcast.autoconfigure;
import org.jspecify.annotations.Nullable;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.core.io.Resource;
import org.springframework.util.Assert;
@ -32,13 +34,13 @@ public class HazelcastProperties { @@ -32,13 +34,13 @@ public class HazelcastProperties {
/**
* The location of the configuration file to use to initialize Hazelcast.
*/
private Resource config;
private @Nullable Resource config;
public Resource getConfig() {
public @Nullable Resource getConfig() {
return this.config;
}
public void setConfig(Resource config) {
public void setConfig(@Nullable Resource config) {
this.config = config;
}
@ -48,13 +50,13 @@ public class HazelcastProperties { @@ -48,13 +50,13 @@ public class HazelcastProperties {
* @throws IllegalArgumentException if the config attribute is set to an unknown
* location
*/
public Resource resolveConfigLocation() {
if (this.config == null) {
public @Nullable Resource resolveConfigLocation() {
Resource config = this.config;
if (config == null) {
return null;
}
Assert.state(this.config.exists(),
() -> "Hazelcast configuration does not exist '" + this.config.getDescription() + "'");
return this.config;
Assert.state(config.exists(), () -> "Hazelcast configuration does not exist '" + config.getDescription() + "'");
return config;
}
}

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

@ -17,4 +17,7 @@ @@ -17,4 +17,7 @@
/**
* Auto-configuration for Hazelcast health.
*/
@NullMarked
package org.springframework.boot.hazelcast.autoconfigure.health;
import org.jspecify.annotations.NullMarked;

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

@ -17,4 +17,7 @@ @@ -17,4 +17,7 @@
/**
* Auto-configuration for Hazelcast.
*/
@NullMarked
package org.springframework.boot.hazelcast.autoconfigure;
import org.jspecify.annotations.NullMarked;

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

@ -18,6 +18,8 @@ package org.springframework.boot.hazelcast.docker.compose; @@ -18,6 +18,8 @@ package org.springframework.boot.hazelcast.docker.compose;
import java.util.Map;
import org.jspecify.annotations.Nullable;
/**
* Hazelcast environment details.
*
@ -25,13 +27,13 @@ import java.util.Map; @@ -25,13 +27,13 @@ import java.util.Map;
*/
class HazelcastEnvironment {
private final String clusterName;
private final @Nullable String clusterName;
HazelcastEnvironment(Map<String, String> env) {
this.clusterName = env.get("HZ_CLUSTERNAME");
}
String getClusterName() {
@Nullable String getClusterName() {
return this.clusterName;
}

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

@ -17,4 +17,7 @@ @@ -17,4 +17,7 @@
/**
* Support for Docker Compose Hazelcast service connections.
*/
@NullMarked
package org.springframework.boot.hazelcast.docker.compose;
import org.jspecify.annotations.NullMarked;

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

@ -17,4 +17,7 @@ @@ -17,4 +17,7 @@
/**
* Health integration for Hazelcast.
*/
@NullMarked
package org.springframework.boot.hazelcast.health;
import org.jspecify.annotations.NullMarked;

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

@ -17,4 +17,7 @@ @@ -17,4 +17,7 @@
/**
* Support for testcontainers Hazelcast service connections.
*/
@NullMarked
package org.springframework.boot.hazelcast.testcontainers;
import org.jspecify.annotations.NullMarked;

Loading…
Cancel
Save