mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-17 12:09:16 +00:00
Add nullability annotations to module/spring-boot-neo4j
See gh-46587
This commit is contained in:
+4
-3
@@ -23,6 +23,7 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.neo4j.driver.AuthToken;
|
||||
import org.neo4j.driver.AuthTokenManager;
|
||||
import org.neo4j.driver.AuthTokens;
|
||||
@@ -185,9 +186,9 @@ public final class Neo4jAutoConfiguration {
|
||||
|
||||
private final Neo4jProperties properties;
|
||||
|
||||
private final AuthTokenManager authTokenManager;
|
||||
private final @Nullable AuthTokenManager authTokenManager;
|
||||
|
||||
PropertiesNeo4jConnectionDetails(Neo4jProperties properties, AuthTokenManager authTokenManager) {
|
||||
PropertiesNeo4jConnectionDetails(Neo4jProperties properties, @Nullable AuthTokenManager authTokenManager) {
|
||||
this.properties = properties;
|
||||
this.authTokenManager = authTokenManager;
|
||||
}
|
||||
@@ -219,7 +220,7 @@ public final class Neo4jAutoConfiguration {
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthTokenManager getAuthTokenManager() {
|
||||
public @Nullable AuthTokenManager getAuthTokenManager() {
|
||||
return this.authTokenManager;
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -18,6 +18,7 @@ package org.springframework.boot.neo4j.autoconfigure;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.neo4j.driver.AuthToken;
|
||||
import org.neo4j.driver.AuthTokenManager;
|
||||
import org.neo4j.driver.AuthTokens;
|
||||
@@ -55,7 +56,7 @@ public interface Neo4jConnectionDetails extends ConnectionDetails {
|
||||
* {@code null} in which case the {@link #getAuthToken() auth token} should be used.
|
||||
* @return the auth token manager
|
||||
*/
|
||||
default AuthTokenManager getAuthTokenManager() {
|
||||
default @Nullable AuthTokenManager getAuthTokenManager() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
+23
-21
@@ -20,6 +20,8 @@ import java.io.File;
|
||||
import java.net.URI;
|
||||
import java.time.Duration;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
@@ -35,7 +37,7 @@ public class Neo4jProperties {
|
||||
/**
|
||||
* URI used by the driver.
|
||||
*/
|
||||
private URI uri;
|
||||
private @Nullable URI uri;
|
||||
|
||||
/**
|
||||
* Timeout for borrowing connections from the pool.
|
||||
@@ -53,11 +55,11 @@ public class Neo4jProperties {
|
||||
|
||||
private final Security security = new Security();
|
||||
|
||||
public URI getUri() {
|
||||
public @Nullable URI getUri() {
|
||||
return this.uri;
|
||||
}
|
||||
|
||||
public void setUri(URI uri) {
|
||||
public void setUri(@Nullable URI uri) {
|
||||
this.uri = uri;
|
||||
}
|
||||
|
||||
@@ -94,53 +96,53 @@ public class Neo4jProperties {
|
||||
/**
|
||||
* Login user of the server.
|
||||
*/
|
||||
private String username;
|
||||
private @Nullable String username;
|
||||
|
||||
/**
|
||||
* Login password of the server.
|
||||
*/
|
||||
private String password;
|
||||
private @Nullable String password;
|
||||
|
||||
/**
|
||||
* Realm to connect to.
|
||||
*/
|
||||
private String realm;
|
||||
private @Nullable String realm;
|
||||
|
||||
/**
|
||||
* Kerberos ticket for connecting to the database. Mutual exclusive with a given
|
||||
* username.
|
||||
*/
|
||||
private String kerberosTicket;
|
||||
private @Nullable String kerberosTicket;
|
||||
|
||||
public String getUsername() {
|
||||
public @Nullable String getUsername() {
|
||||
return this.username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
public void setUsername(@Nullable String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
public @Nullable String getPassword() {
|
||||
return this.password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
public void setPassword(@Nullable String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getRealm() {
|
||||
public @Nullable String getRealm() {
|
||||
return this.realm;
|
||||
}
|
||||
|
||||
public void setRealm(String realm) {
|
||||
public void setRealm(@Nullable String realm) {
|
||||
this.realm = realm;
|
||||
}
|
||||
|
||||
public String getKerberosTicket() {
|
||||
public @Nullable String getKerberosTicket() {
|
||||
return this.kerberosTicket;
|
||||
}
|
||||
|
||||
public void setKerberosTicket(String kerberosTicket) {
|
||||
public void setKerberosTicket(@Nullable String kerberosTicket) {
|
||||
this.kerberosTicket = kerberosTicket;
|
||||
}
|
||||
|
||||
@@ -167,7 +169,7 @@ public class Neo4jProperties {
|
||||
* Pooled connections that have been idle in the pool for longer than this
|
||||
* threshold will be tested before they are used again.
|
||||
*/
|
||||
private Duration idleTimeBeforeConnectionTest;
|
||||
private @Nullable Duration idleTimeBeforeConnectionTest;
|
||||
|
||||
/**
|
||||
* Pooled connections older than this threshold will be closed and removed from
|
||||
@@ -197,11 +199,11 @@ public class Neo4jProperties {
|
||||
this.maxConnectionPoolSize = maxConnectionPoolSize;
|
||||
}
|
||||
|
||||
public Duration getIdleTimeBeforeConnectionTest() {
|
||||
public @Nullable Duration getIdleTimeBeforeConnectionTest() {
|
||||
return this.idleTimeBeforeConnectionTest;
|
||||
}
|
||||
|
||||
public void setIdleTimeBeforeConnectionTest(Duration idleTimeBeforeConnectionTest) {
|
||||
public void setIdleTimeBeforeConnectionTest(@Nullable Duration idleTimeBeforeConnectionTest) {
|
||||
this.idleTimeBeforeConnectionTest = idleTimeBeforeConnectionTest;
|
||||
}
|
||||
|
||||
@@ -246,7 +248,7 @@ public class Neo4jProperties {
|
||||
/**
|
||||
* Path to the file that holds the trusted certificates.
|
||||
*/
|
||||
private File certFile;
|
||||
private @Nullable File certFile;
|
||||
|
||||
/**
|
||||
* Whether hostname verification is required.
|
||||
@@ -269,11 +271,11 @@ public class Neo4jProperties {
|
||||
this.trustStrategy = trustStrategy;
|
||||
}
|
||||
|
||||
public File getCertFile() {
|
||||
public @Nullable File getCertFile() {
|
||||
return this.certFile;
|
||||
}
|
||||
|
||||
public void setCertFile(File certFile) {
|
||||
public void setCertFile(@Nullable File certFile) {
|
||||
this.certFile = certFile;
|
||||
}
|
||||
|
||||
|
||||
+3
@@ -17,4 +17,7 @@
|
||||
/**
|
||||
* Auto-configuration for Neo4j health.
|
||||
*/
|
||||
@NullMarked
|
||||
package org.springframework.boot.neo4j.autoconfigure.health;
|
||||
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
+3
@@ -17,4 +17,7 @@
|
||||
/**
|
||||
* Auto-configuration for Neo4j.
|
||||
*/
|
||||
@NullMarked
|
||||
package org.springframework.boot.neo4j.autoconfigure;
|
||||
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
+4
-2
@@ -18,7 +18,9 @@ package org.springframework.boot.neo4j.docker.compose;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.neo4j.driver.AuthToken;
|
||||
import org.neo4j.driver.AuthTokens;
|
||||
|
||||
import org.springframework.boot.docker.compose.core.RunningService;
|
||||
import org.springframework.boot.docker.compose.service.connection.DockerComposeConnectionDetailsFactory;
|
||||
@@ -53,7 +55,7 @@ class Neo4jDockerComposeConnectionDetailsFactory extends DockerComposeConnection
|
||||
|
||||
private static final int BOLT_PORT = 7687;
|
||||
|
||||
private final AuthToken authToken;
|
||||
private final @Nullable AuthToken authToken;
|
||||
|
||||
private final URI uri;
|
||||
|
||||
@@ -71,7 +73,7 @@ class Neo4jDockerComposeConnectionDetailsFactory extends DockerComposeConnection
|
||||
|
||||
@Override
|
||||
public AuthToken getAuthToken() {
|
||||
return this.authToken;
|
||||
return (this.authToken != null) ? this.authToken : AuthTokens.none();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+4
-3
@@ -18,6 +18,7 @@ package org.springframework.boot.neo4j.docker.compose;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.neo4j.driver.AuthToken;
|
||||
import org.neo4j.driver.AuthTokens;
|
||||
|
||||
@@ -29,7 +30,7 @@ import org.neo4j.driver.AuthTokens;
|
||||
*/
|
||||
class Neo4jEnvironment {
|
||||
|
||||
private final AuthToken authToken;
|
||||
private final @Nullable AuthToken authToken;
|
||||
|
||||
Neo4jEnvironment(Map<String, String> env) {
|
||||
AuthToken authToken = parse(env.get("NEO4J_AUTH"));
|
||||
@@ -39,7 +40,7 @@ class Neo4jEnvironment {
|
||||
this.authToken = authToken;
|
||||
}
|
||||
|
||||
private AuthToken parse(String neo4jAuth) {
|
||||
private @Nullable AuthToken parse(@Nullable String neo4jAuth) {
|
||||
if (neo4jAuth == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -55,7 +56,7 @@ class Neo4jEnvironment {
|
||||
+ " the neo4j user's password");
|
||||
}
|
||||
|
||||
AuthToken getAuthToken() {
|
||||
@Nullable AuthToken getAuthToken() {
|
||||
return this.authToken;
|
||||
}
|
||||
|
||||
|
||||
+3
@@ -17,4 +17,7 @@
|
||||
/**
|
||||
* Support for Docker Compose Neo4J service connections.
|
||||
*/
|
||||
@NullMarked
|
||||
package org.springframework.boot.neo4j.docker.compose;
|
||||
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
+4
-1
@@ -18,6 +18,7 @@ package org.springframework.boot.neo4j.health;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.neo4j.driver.Driver;
|
||||
import org.neo4j.driver.Record;
|
||||
import org.neo4j.driver.exceptions.SessionExpiredException;
|
||||
@@ -31,6 +32,7 @@ import reactor.util.retry.Retry;
|
||||
import org.springframework.boot.health.contributor.AbstractReactiveHealthIndicator;
|
||||
import org.springframework.boot.health.contributor.Health;
|
||||
import org.springframework.boot.health.contributor.ReactiveHealthIndicator;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* {@link ReactiveHealthIndicator} that tests the status of a Neo4j by executing a Cypher
|
||||
@@ -90,13 +92,14 @@ public final class Neo4jReactiveHealthIndicator extends AbstractReactiveHealthIn
|
||||
*/
|
||||
private static final class Neo4jHealthDetailsBuilder {
|
||||
|
||||
private Record record;
|
||||
private @Nullable Record record;
|
||||
|
||||
void record(Record record) {
|
||||
this.record = record;
|
||||
}
|
||||
|
||||
private Neo4jHealthDetails build(ResultSummary summary) {
|
||||
Assert.state(this.record != null, "'record' must not be null");
|
||||
return new Neo4jHealthDetails(this.record, summary);
|
||||
}
|
||||
|
||||
|
||||
+3
@@ -17,4 +17,7 @@
|
||||
/**
|
||||
* Health integration for Neo4j.
|
||||
*/
|
||||
@NullMarked
|
||||
package org.springframework.boot.neo4j.health;
|
||||
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
+3
@@ -17,4 +17,7 @@
|
||||
/**
|
||||
* Support for testcontainers Neo4J service connections.
|
||||
*/
|
||||
@NullMarked
|
||||
package org.springframework.boot.neo4j.testcontainers;
|
||||
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
Reference in New Issue
Block a user