Skip to content

Commit 73bba49

Browse files
authored
jspecify, archunit (#43)
* update to spring boot 4 and fix update issues * add jspecify, nullaway, archunit and fix things * add utility for nullchecking * fix nullability issues * fix query transformer and some other issues * fixes and archunit * fix issues
1 parent bee0fed commit 73bba49

204 files changed

Lines changed: 1814 additions & 944 deletions

File tree

Some content is hidden

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

.idea/codeStyles/Project.xml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lombok.config

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
config.stopBubbling = true
2+
3+
# Required for NullAway to work
4+
lombok.addLombokGeneratedAnnotation = true
5+
6+
# Copy JSpecify annotations to generated code (constructors, getters, setters)
7+
lombok.copyableAnnotations += org.jspecify.annotations.Nullable
8+
lombok.copyableAnnotations += org.jspecify.annotations.NonNull
9+
lombok.addNullAnnotations = jspecify

pom.xml

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
34
<modelVersion>4.0.0</modelVersion>
45

56
<parent>
67
<groupId>org.springframework.boot</groupId>
78
<artifactId>spring-boot-starter-parent</artifactId>
8-
<version>4.0.0</version>
9+
<version>4.0.1</version>
910
<relativePath/> <!-- lookup parent from repository -->
1011
</parent>
1112

@@ -17,8 +18,20 @@
1718

1819
<properties>
1920
<java.version>25</java.version>
21+
<errorprone.version>2.45.0</errorprone.version>
22+
<nullaway.version>0.12.14</nullaway.version>
2023
</properties>
2124

25+
<dependencyManagement>
26+
<dependencies>
27+
<dependency>
28+
<groupId>it.aboutbits</groupId>
29+
<artifactId>archunit-toolbox</artifactId>
30+
<version>1.0.0-RC1</version>
31+
</dependency>
32+
</dependencies>
33+
</dependencyManagement>
34+
2235
<dependencies>
2336
<dependency>
2437
<groupId>org.springframework.boot</groupId>
@@ -135,6 +148,26 @@
135148
<version>2.0.2</version>
136149
<scope>test</scope>
137150
</dependency>
151+
152+
<!-- https://mvnrepository.com/artifact/com.tngtech.archunit/archunit-junit5 -->
153+
<dependency>
154+
<groupId>com.tngtech.archunit</groupId>
155+
<artifactId>archunit-junit5</artifactId>
156+
<version>1.4.1</version>
157+
<scope>test</scope>
158+
</dependency>
159+
<dependency>
160+
<groupId>com.tngtech.archunit</groupId>
161+
<artifactId>archunit-junit5-api</artifactId>
162+
<version>1.4.1</version>
163+
<scope>compile</scope>
164+
</dependency>
165+
166+
<dependency>
167+
<groupId>it.aboutbits</groupId>
168+
<artifactId>archunit-toolbox</artifactId>
169+
<scope>test</scope>
170+
</dependency>
138171
</dependencies>
139172

140173
<build>
@@ -156,7 +189,36 @@
156189
<artifactId>lombok</artifactId>
157190
<version>${lombok.version}</version>
158191
</path>
192+
<path>
193+
<groupId>com.google.errorprone</groupId>
194+
<artifactId>error_prone_core</artifactId>
195+
<version>${errorprone.version}</version>
196+
</path>
197+
<path>
198+
<groupId>com.uber.nullaway</groupId>
199+
<artifactId>nullaway</artifactId>
200+
<version>${nullaway.version}</version>
201+
</path>
159202
</annotationProcessorPaths>
203+
<compilerArgs>
204+
<arg>-Amapstruct.unmappedTargetPolicy=ERROR</arg>
205+
<arg>-XDcompilePolicy=simple</arg>
206+
<arg>--should-stop=ifError=FLOW</arg>
207+
<!-- @formatter:off -->
208+
<arg>-Xplugin:ErrorProne -XepDisableAllChecks -XepOpt:NullAway:AnnotatedPackages=it.aboutbits.springboot.toolbox -XepOpt:NullAway:JSpecifyMode=true -Xep:NullAway:ERROR -XepOpt:NullAway:ExcludedFieldAnnotations=org.mockito.InjectMocks,org.mockito.Mock</arg>
209+
<!-- @formatter:on -->
210+
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED</arg>
211+
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED</arg>
212+
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED</arg>
213+
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED</arg>
214+
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED</arg>
215+
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED</arg>
216+
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED</arg>
217+
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED</arg>
218+
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED</arg>
219+
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED</arg>
220+
</compilerArgs>
221+
<fork>true</fork>
160222
</configuration>
161223
</plugin>
162224
<plugin>

src/main/java/it/aboutbits/springboot/toolbox/autoconfiguration/persistence/AbstractCustomTypeContributor.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
import org.hibernate.boot.model.TypeContributor;
77
import org.hibernate.service.ServiceRegistry;
88
import org.hibernate.type.descriptor.java.JavaType;
9+
import org.jspecify.annotations.NullMarked;
910

1011
import java.lang.reflect.InvocationTargetException;
1112
import java.util.Set;
1213

14+
@NullMarked
1315
public abstract class AbstractCustomTypeContributor implements TypeContributor {
1416
@SuppressWarnings("rawtypes")
1517
private final Set<Class<? extends AutoRegisteredJavaType>> relevantTypes;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package it.aboutbits.springboot.toolbox.autoconfiguration.persistence;
22

33
import org.hibernate.type.descriptor.java.JavaType;
4+
import org.jspecify.annotations.NullMarked;
45

6+
@NullMarked
57
public interface AutoRegisteredJavaType<T> extends JavaType<T> {
68
}

src/main/java/it/aboutbits/springboot/toolbox/autoconfiguration/persistence/CustomTypeContributor.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package it.aboutbits.springboot.toolbox.autoconfiguration.persistence;
22

3+
import org.jspecify.annotations.NullMarked;
4+
5+
@NullMarked
36
public final class CustomTypeContributor extends AbstractCustomTypeContributor {
47
public CustomTypeContributor() {
58
super("it.aboutbits.springboot.toolbox");

src/main/java/it/aboutbits/springboot/toolbox/autoconfiguration/web/CustomTypeConfiguration.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import it.aboutbits.springboot.toolbox.type.identity.EntityId;
88
import it.aboutbits.springboot.toolbox.web.CustomTypePropertyEditor;
99
import it.aboutbits.springboot.toolbox.web.EntityIdPropertyEditor;
10+
import org.jspecify.annotations.NullMarked;
1011
import org.springframework.boot.jackson.autoconfigure.JsonMapperBuilderCustomizer;
1112
import org.springframework.context.annotation.Bean;
1213
import org.springframework.context.annotation.Configuration;
@@ -18,6 +19,7 @@
1819
import java.util.Set;
1920

2021
@Configuration
22+
@NullMarked
2123
public class CustomTypeConfiguration {
2224
@ControllerAdvice
2325
public static class CustomTypePropertyBinder {
@@ -46,8 +48,8 @@ public JsonMapperBuilderCustomizer jsonCustomizer(CustomTypeScanner configuratio
4648

4749
// dynamic deserializers
4850
configuration.getRelevantTypes()
49-
.forEach(type ->
50-
module.addDeserializer(type, new CustomTypeDeserializer(type))
51+
.forEach(
52+
type -> module.addDeserializer(type, new CustomTypeDeserializer(type))
5153
);
5254

5355
// type-based deserializer
@@ -56,5 +58,4 @@ public JsonMapperBuilderCustomizer jsonCustomizer(CustomTypeScanner configuratio
5658
return builder -> builder
5759
.addModule(module);
5860
}
59-
6061
}

src/main/java/it/aboutbits/springboot/toolbox/autoconfiguration/web/CustomTypeScanner.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import it.aboutbits.springboot.toolbox.type.CustomType;
55
import lombok.Getter;
66
import lombok.extern.slf4j.Slf4j;
7+
import org.jspecify.annotations.NullMarked;
78

89
import java.lang.annotation.ElementType;
910
import java.lang.annotation.Retention;
@@ -18,6 +19,7 @@
1819

1920
@Slf4j
2021
@Getter
22+
@NullMarked
2123
public class CustomTypeScanner {
2224
private static final String LIBRARY_BASE_PACKAGE_NAME = "it.aboutbits.springboot.toolbox";
2325

src/main/java/it/aboutbits/springboot/toolbox/autoconfiguration/web/CustomTypeScannerRegistrar.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package it.aboutbits.springboot.toolbox.autoconfiguration.web;
22

3+
import org.jspecify.annotations.NullMarked;
34
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
45
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
56
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
@@ -8,6 +9,7 @@
89

910
import java.util.Objects;
1011

12+
@NullMarked
1113
public class CustomTypeScannerRegistrar implements ImportBeanDefinitionRegistrar {
1214

1315
/**

src/main/java/it/aboutbits/springboot/toolbox/autoconfiguration/web/RegisterCustomTypesWithJacksonAndMvc.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package it.aboutbits.springboot.toolbox.autoconfiguration.web;
22

3+
import org.jspecify.annotations.NullMarked;
34
import org.springframework.context.annotation.Import;
45

56
import java.lang.annotation.ElementType;
@@ -10,6 +11,7 @@
1011
@Target({ElementType.TYPE})
1112
@Retention(RetentionPolicy.RUNTIME)
1213
@Import({CustomTypeScannerRegistrar.class, CustomTypeConfiguration.class})
14+
@NullMarked
1315
public @interface RegisterCustomTypesWithJacksonAndMvc {
1416
String[] additionalTypePackages() default "";
1517
}

0 commit comments

Comments
 (0)