Skip to content

Commit e4b2fd1

Browse files
committed
Nullabbility.
1 parent 60561c3 commit e4b2fd1

File tree

136 files changed

+345
-214
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+345
-214
lines changed

.mvn/jvm.config

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
2+
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
3+
--add-exports jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED
4+
--add-exports jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED
5+
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
6+
--add-exports jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED
7+
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
8+
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
9+
--add-opens jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
10+
--add-opens jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED
11+
--add-opens=java.base/java.util=ALL-UNNAMED
12+
--add-opens=java.base/java.lang.reflect=ALL-UNNAMED
13+
--add-opens=java.base/java.text=ALL-UNNAMED
14+
--add-opens=java.desktop/java.awt.font=ALL-UNNAMED

pom.xml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<assertj-core.version>3.27.3</assertj-core.version>
2424
<aws-java-sdk.version>2.31.29</aws-java-sdk.version>
2525
<bcpkix-jdk18on.version>1.80</bcpkix-jdk18on.version>
26+
<errorprone.version>2.36.0</errorprone.version>
2627
<google-api-services-iam.version>v1-rev20221013-2.0.0
2728
</google-api-services-iam.version>
2829
<google-cloud-iamcredentials.version>2.60.0</google-cloud-iamcredentials.version>
@@ -39,6 +40,7 @@
3940
<mockk.version>1.13.17</mockk.version>
4041
<mockito-core.version>5.17.0</mockito-core.version>
4142
<netty.version>4.1.121.Final</netty.version>
43+
<nullaway.version>0.12.3</nullaway.version>
4244
<okhttp3.version>3.14.9</okhttp3.version>
4345
<spring.version>7.0.0-M2</spring.version>
4446
<spring-data-bom.version>2025.1.0-M1</spring-data-bom.version>
@@ -379,9 +381,22 @@
379381
<groupId>org.apache.maven.plugins</groupId>
380382
<artifactId>maven-compiler-plugin</artifactId>
381383
<configuration>
382-
<source>${java.version}</source>
383-
<target>${java.version}</target>
384+
<release>${java.version}</release>
384385
<parameters>true</parameters>
386+
<release>${source.level}</release>
387+
<showWarnings>true</showWarnings>
388+
<annotationProcessorPaths>
389+
<path>
390+
<groupId>com.google.errorprone</groupId>
391+
<artifactId>error_prone_core</artifactId>
392+
<version>${errorprone.version}</version>
393+
</path>
394+
<path>
395+
<groupId>com.uber.nullaway</groupId>
396+
<artifactId>nullaway</artifactId>
397+
<version>${nullaway.version}</version>
398+
</path>
399+
</annotationProcessorPaths>
385400
</configuration>
386401
<executions>
387402
<execution>
@@ -398,6 +413,13 @@
398413
<goals>
399414
<goal>compile</goal>
400415
</goals>
416+
<configuration>
417+
<compilerArgs>
418+
<arg>-XDcompilePolicy=simple</arg>
419+
<arg>--should-stop=ifError=FLOW</arg>
420+
<arg>-Xplugin:ErrorProne -XepDisableAllChecks -Xep:NullAway:ERROR -XepOpt:NullAway:OnlyNullMarked=true -XepOpt:NullAway:CustomContractAnnotations=org.springframework.lang.Contract</arg>
421+
</compilerArgs>
422+
</configuration>
401423
</execution>
402424
<execution>
403425
<id>java-test-compile</id>

spring-vault-core/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@
135135
<artifactId>kotlinx-coroutines-reactor</artifactId>
136136
<optional>true</optional>
137137
</dependency>
138+
<dependency>
139+
<groupId>org.jspecify</groupId>
140+
<artifactId>jspecify</artifactId>
141+
<version>1.0.0</version>
142+
</dependency>
138143

139144
<!-- HTTP clients -->
140145

spring-vault-core/src/main/java/org/springframework/vault/annotation/PropertySourceAotProcessor.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
import java.util.Map.Entry;
1919
import java.util.function.Predicate;
2020

21+
import org.jspecify.annotations.Nullable;
22+
2123
import org.springframework.aot.generate.GenerationContext;
2224
import org.springframework.beans.factory.aot.BeanRegistrationAotContribution;
2325
import org.springframework.beans.factory.aot.BeanRegistrationAotProcessor;
@@ -31,7 +33,6 @@
3133
import org.springframework.beans.factory.support.RegisteredBean;
3234
import org.springframework.beans.factory.support.RootBeanDefinition;
3335
import org.springframework.javapoet.CodeBlock;
34-
import org.springframework.lang.Nullable;
3536
import org.springframework.util.ClassUtils;
3637
import org.springframework.vault.core.lease.domain.RequestedSecret;
3738
import org.springframework.vault.core.lease.domain.RequestedSecret.Mode;
@@ -48,7 +49,7 @@
4849
class PropertySourceAotProcessor implements BeanRegistrationAotProcessor {
4950

5051
@Override
51-
public BeanRegistrationAotContribution processAheadOfTime(RegisteredBean registeredBean) {
52+
public @Nullable BeanRegistrationAotContribution processAheadOfTime(RegisteredBean registeredBean) {
5253

5354
if (registeredBean.getBeanClass() == org.springframework.vault.core.env.LeaseAwareVaultPropertySource.class) {
5455
return BeanRegistrationAotContribution.withCustomCodeFragments(AotContribution::new);

spring-vault-core/src/main/java/org/springframework/vault/annotation/VaultPropertySource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
*/
114114
Renewal renewal() default Renewal.OFF;
115115

116-
public enum Renewal {
116+
enum Renewal {
117117

118118
/**
119119
* Do not renew leases associated with secrets.

spring-vault-core/src/main/java/org/springframework/vault/annotation/VaultPropertySourceRegistrar.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import java.util.Map;
2222
import java.util.Set;
2323

24+
import org.jspecify.annotations.Nullable;
25+
2426
import org.springframework.beans.BeansException;
2527
import org.springframework.beans.factory.config.BeanDefinition;
2628
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
@@ -36,7 +38,6 @@
3638
import org.springframework.core.env.MutablePropertySources;
3739
import org.springframework.core.env.PropertySource;
3840
import org.springframework.core.type.AnnotationMetadata;
39-
import org.springframework.lang.Nullable;
4041
import org.springframework.util.Assert;
4142
import org.springframework.util.StringUtils;
4243
import org.springframework.vault.annotation.VaultPropertySource.Renewal;
@@ -200,17 +201,17 @@ static Set<AnnotationAttributes> attributesForRepeatable(AnnotationMetadata meta
200201
Set<AnnotationAttributes> result = new LinkedHashSet<>();
201202
addAttributesIfNotNull(result, metadata.getAnnotationAttributes(annotationClassName, false));
202203

203-
Map<String, Object> container = metadata.getAnnotationAttributes(containerClassName, false);
204+
Map<String, @Nullable Object> container = metadata.getAnnotationAttributes(containerClassName, false);
204205
if (container != null && container.containsKey("value")) {
205-
for (Map<String, Object> containedAttributes : (Map<String, Object>[]) container.get("value")) {
206+
for (Map<String, Object> containedAttributes : (Map<String, @Nullable Object>[]) container.get("value")) {
206207
addAttributesIfNotNull(result, containedAttributes);
207208
}
208209
}
209210
return Collections.unmodifiableSet(result);
210211
}
211212

212213
private static void addAttributesIfNotNull(Set<AnnotationAttributes> result,
213-
@Nullable Map<String, Object> attributes) {
214+
@Nullable Map<String, @Nullable Object> attributes) {
214215
if (attributes != null) {
215216
result.add(AnnotationAttributes.fromMap(attributes));
216217
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/**
22
* Annotation support for the Spring Vault.
33
*/
4-
@org.springframework.lang.NonNullApi
5-
@org.springframework.lang.NonNullFields
4+
@org.jspecify.annotations.NullMarked
65
package org.springframework.vault.annotation;

spring-vault-core/src/main/java/org/springframework/vault/aot/VaultRuntimeHints.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
import java.io.IOException;
1919
import java.util.stream.Stream;
2020

21+
import org.jspecify.annotations.Nullable;
22+
2123
import org.springframework.aot.hint.MemberCategory;
2224
import org.springframework.aot.hint.ReflectionHints;
2325
import org.springframework.aot.hint.RuntimeHints;
@@ -41,7 +43,7 @@ class VaultRuntimeHints implements RuntimeHintsRegistrar {
4143
private final CachingMetadataReaderFactory factory = new CachingMetadataReaderFactory();
4244

4345
@Override
44-
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
46+
public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) {
4547

4648
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(classLoader);
4749

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/**
22
* Ahead-of-Time support.
33
*/
4-
@org.springframework.lang.NonNullApi
5-
@org.springframework.lang.NonNullFields
4+
@org.jspecify.annotations.NullMarked
65
package org.springframework.vault.aot;

spring-vault-core/src/main/java/org/springframework/vault/authentication/AppRoleAuthentication.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020

2121
import org.apache.commons.logging.Log;
2222
import org.apache.commons.logging.LogFactory;
23+
import org.jspecify.annotations.Nullable;
2324

2425
import org.springframework.http.HttpEntity;
2526
import org.springframework.http.HttpHeaders;
2627
import org.springframework.http.HttpMethod;
2728
import org.springframework.http.ResponseEntity;
28-
import org.springframework.lang.Nullable;
2929
import org.springframework.util.Assert;
3030
import org.springframework.util.ClassUtils;
3131
import org.springframework.vault.authentication.AppRoleAuthenticationOptions.RoleId;
@@ -214,7 +214,7 @@ private String getRoleId(RoleId roleId) throws VaultLoginException {
214214

215215
ResponseEntity<VaultResponse> entity = this.restOperations.exchange(getRoleIdIdPath(this.options),
216216
HttpMethod.GET, createHttpEntity(token), VaultResponse.class);
217-
return (String) entity.getBody().getRequiredData().get("role_id");
217+
return (String) ResponseUtil.getRequiredData(entity).get("role_id");
218218
}
219219
catch (HttpStatusCodeException e) {
220220
throw new VaultLoginException("Cannot get Role id using AppRole: %s"
@@ -231,7 +231,7 @@ private String getRoleId(RoleId roleId) throws VaultLoginException {
231231
ResponseEntity<VaultResponse> entity = this.restOperations.exchange(unwrappingEndpoints.getPath(),
232232
unwrappingEndpoints.getUnwrapRequestMethod(), createHttpEntity(token), VaultResponse.class);
233233

234-
VaultResponse response = unwrappingEndpoints.unwrap(entity.getBody());
234+
VaultResponse response = unwrappingEndpoints.unwrap(ResponseUtil.getRequiredBody(entity));
235235

236236
return (String) response.getRequiredData().get("role_id");
237237
}
@@ -257,7 +257,7 @@ private String getSecretId(SecretId secretId) throws VaultLoginException {
257257
try {
258258
VaultResponse response = this.restOperations.postForObject(getSecretIdPath(this.options),
259259
createHttpEntity(token), VaultResponse.class);
260-
return (String) response.getRequiredData().get("secret_id");
260+
return (String) ResponseUtil.getRequiredData(response).get("secret_id");
261261
}
262262
catch (HttpStatusCodeException e) {
263263
throw new VaultLoginException("Cannot get Secret id using AppRole: %s"
@@ -275,7 +275,7 @@ private String getSecretId(SecretId secretId) throws VaultLoginException {
275275
ResponseEntity<VaultResponse> entity = this.restOperations.exchange(unwrappingEndpoints.getPath(),
276276
unwrappingEndpoints.getUnwrapRequestMethod(), createHttpEntity(token), VaultResponse.class);
277277

278-
VaultResponse response = unwrappingEndpoints.unwrap(entity.getBody());
278+
VaultResponse response = unwrappingEndpoints.unwrap(ResponseUtil.getRequiredBody(entity));
279279

280280
return (String) response.getRequiredData().get("secret_id");
281281
}

0 commit comments

Comments
 (0)