Skip to content

Commit 2bfcf95

Browse files
committed
✨ Enabled JSpecify null handling
1 parent a795267 commit 2bfcf95

20 files changed

Lines changed: 278 additions & 109 deletions

File tree

fluentforms/pom.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@
9696
<!-- Project dependecies -->
9797
<aemfd.client.sdk.version>6.1.152</aemfd.client.sdk.version> <!-- fluentforms requires AEM 6.5 SP12 or later -->
9898
<io.wcm.maven.aem-dependencies.version>6.6.0.0000</io.wcm.maven.aem-dependencies.version>
99+
100+
<!-- Eclipse dependencies (for null processing) -->
101+
<eclipse.annotations.version>2.4.100</eclipse.annotations.version>
99102

100103
</properties>
101104

@@ -606,6 +609,12 @@
606609
</dependencyManagement>
607610

608611
<dependencies>
612+
<dependency>
613+
<groupId>org.eclipse.jdt</groupId>
614+
<artifactId>org.eclipse.jdt.annotation</artifactId>
615+
<version>${eclipse.annotations.version}</version>
616+
<optional>true</optional>
617+
</dependency>
609618
<dependency>
610619
<groupId>org.junit.jupiter</groupId>
611620
<artifactId>junit-jupiter</artifactId>

rest-services/it.tests/pom.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
<maven.compiler.source>17</maven.compiler.source>
3737
<maven.compiler.target>17</maven.compiler.target>
3838
<maven.compiler.release>17</maven.compiler.release>
39+
40+
<!-- Null processing -->
41+
<jspecify.version>1.0.0</jspecify.version>
3942
</properties>
4043

4144
<build>
@@ -71,6 +74,13 @@
7174
<artifactId>jersey-hk2</artifactId>
7275
</dependency>
7376
-->
77+
<!-- Null processing (required by JSoup when null processing is enabled) -->
78+
<dependency>
79+
<groupId>org.jspecify</groupId>
80+
<artifactId>jspecify</artifactId>
81+
<version>${jspecify.version}</version>
82+
<optional>true</optional>
83+
</dependency>
7484
<dependency>
7585
<groupId>com._4point.aem</groupId>
7686
<artifactId>fluentforms.core</artifactId>

rest-services/pom.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@
8585
<sling.servlet-helpers.version>1.4.6</sling.servlet-helpers.version>
8686
<fluentforms.version>0.0.5-SNAPSHOT</fluentforms.version>
8787
<rest-services.version>0.0.5-SNAPSHOT</rest-services.version>
88+
89+
<!-- Eclipse dependencies (for null processing) -->
90+
<eclipse.annotations.version>2.4.100</eclipse.annotations.version>
8891

8992
<!-- Testing dependencies -->
9093
<mockito.version>5.18.0</mockito.version>
@@ -546,6 +549,12 @@
546549
</dependencyManagement>
547550

548551
<dependencies>
552+
<dependency>
553+
<groupId>org.eclipse.jdt</groupId>
554+
<artifactId>org.eclipse.jdt.annotation</artifactId>
555+
<version>${eclipse.annotations.version}</version>
556+
<optional>true</optional>
557+
</dependency>
549558
<!-- Testing -->
550559
<dependency>
551560
<groupId>org.junit.jupiter</groupId>

spring/fluentforms-jersey-spring-boot-autoconfigure/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<groupId>org.springframework.boot</groupId>
55
<artifactId>spring-boot-starter-parent</artifactId>
6-
<version>4.0.0</version>
6+
<version>4.0.1</version>
77
<relativePath /> <!-- lookup parent from repository -->
88
</parent>
99
<groupId>com._4point.aem.fluentforms</groupId>

spring/fluentforms-jersey-spring-boot-starter/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>org.springframework.boot</groupId>
88
<artifactId>spring-boot-starter-parent</artifactId>
9-
<version>4.0.0</version>
9+
<version>4.0.1</version>
1010
<relativePath /> <!-- lookup parent from repository -->
1111
</parent>
1212
<artifactId>fluentforms-jersey-spring-boot-starter</artifactId>

spring/fluentforms-sample-web-jersey-app/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>org.springframework.boot</groupId>
77
<artifactId>spring-boot-starter-parent</artifactId>
8-
<version>4.0.0</version>
8+
<version>4.0.1</version>
99
<relativePath /> <!-- lookup parent from repository -->
1010
</parent>
1111
<groupId>com._4point.aem.fluentforms</groupId>

spring/fluentforms-sample-webmvc-app/pom.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>org.springframework.boot</groupId>
77
<artifactId>spring-boot-starter-parent</artifactId>
8-
<version>4.0.0</version>
8+
<version>4.0.1</version>
99
<relativePath /> <!-- lookup parent from repository -->
1010
</parent>
1111
<groupId>com._4point.aem.fluentforms</groupId>
@@ -70,6 +70,10 @@
7070
<artifactId>fluentforms-spring-boot-starter</artifactId>
7171
<version>${fluentforms.spring.boot.starter.version}</version>
7272
</dependency>
73+
<dependency>
74+
<groupId>org.jspecify</groupId>
75+
<artifactId>jspecify</artifactId>
76+
</dependency>
7377

7478
<!-- Testing Dependencies -->
7579
<dependency>

spring/fluentforms-sample-webmvc-app/src/main/java/com/_4point/aem/fluentforms/sampleapp/GitConfig.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com._4point.aem.fluentforms.sampleapp;
22

3+
import org.jspecify.annotations.Nullable;
34
import org.slf4j.Logger;
45
import org.slf4j.LoggerFactory;
56
import org.springframework.beans.factory.annotation.Value;
@@ -13,26 +14,26 @@ public class GitConfig {
1314
private final Logger log = LoggerFactory.getLogger(this.getClass());
1415

1516
@Value("${git.build.time}")
16-
private String commitBuildTime;
17+
@Nullable private String commitBuildTime;
1718
@Value("${git.branch}")
18-
private String branch;
19+
@Nullable private String branch;
1920
@Value("${git.commit.time}")
20-
private String commitTime;
21+
@Nullable private String commitTime;
2122
@Value("${git.commit.id.abbrev}")
22-
private String commitIdAbbrev;
23+
@Nullable private String commitIdAbbrev;
2324
@Value("${git.dirty}")
24-
private String dirty;
25+
@Nullable private String dirty;
2526

26-
public String getCommitBuildTime() {
27+
public @Nullable String getCommitBuildTime() {
2728
return commitBuildTime;
2829
}
29-
public String getBranch() {
30+
public @Nullable String getBranch() {
3031
return branch;
3132
}
32-
public String getCommitTime() {
33+
public @Nullable String getCommitTime() {
3334
return commitTime;
3435
}
35-
public String getCommitIdAbbrev() {
36+
public @Nullable String getCommitIdAbbrev() {
3637
return commitIdAbbrev;
3738
}
3839

spring/fluentforms-spring-boot-autoconfigure/pom.xml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>org.springframework.boot</groupId>
77
<artifactId>spring-boot-starter-parent</artifactId>
8-
<version>4.0.0</version>
8+
<version>4.0.1</version>
99
<relativePath /> <!-- lookup parent from repository -->
1010
</parent>
1111
<groupId>com._4point.aem.fluentforms</groupId>
@@ -18,6 +18,7 @@
1818
<jasypt.spring.boot.version>3.0.5</jasypt.spring.boot.version>
1919
<jasypt.maven.plugin.version>3.0.5</jasypt.maven.plugin.version>
2020
<fluentforms.version>0.0.5-SNAPSHOT</fluentforms.version>
21+
<eclipse.annotations.version>2.4.100</eclipse.annotations.version>
2122
<fp.hamcrest.matchers.version>0.0.4-SNAPSHOT</fp.hamcrest.matchers.version>
2223
<wiremock.version>4.0.0-beta.22</wiremock.version>
2324
<wiremock-spring-boot.version>4.0.8</wiremock-spring-boot.version>
@@ -77,6 +78,17 @@
7778
<optional>true</optional>
7879
<scope>provided</scope>
7980
</dependency>
81+
<dependency>
82+
<groupId>org.jspecify</groupId>
83+
<artifactId>jspecify</artifactId>
84+
<optional>true</optional>
85+
</dependency>
86+
<dependency>
87+
<groupId>org.eclipse.jdt</groupId>
88+
<artifactId>org.eclipse.jdt.annotation</artifactId>
89+
<version>${eclipse.annotations.version}</version>
90+
<optional>true</optional>
91+
</dependency>
8092
<dependency>
8193
<groupId>com._4point.aem</groupId>
8294
<artifactId>fluentforms.core</artifactId>
@@ -124,6 +136,11 @@
124136
<version>${pitest.junit5.maven.plugin.version}</version>
125137
<scope>test</scope>
126138
</dependency>
139+
<dependency>
140+
<groupId>org.springframework.boot</groupId>
141+
<artifactId>spring-boot-configuration-processor</artifactId>
142+
<optional>true</optional>
143+
</dependency>
127144
</dependencies>
128145
<build>
129146
<plugins>

spring/fluentforms-spring-boot-autoconfigure/src/main/java/com/_4point/aem/fluentforms/spring/AemConfiguration.java

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com._4point.aem.fluentforms.spring;
22

3+
import java.util.Optional;
4+
35
import org.springframework.boot.context.properties.ConfigurationProperties;
46
import org.springframework.boot.context.properties.bind.DefaultValue;
57

@@ -16,7 +18,7 @@
1618
*
1719
*/
1820
@EnableEncryptableProperties
19-
@ConfigurationProperties("fluentforms.aem")
21+
@ConfigurationProperties(AemConfiguration.CONFIGURATION_PREFIX)
2022
public record AemConfiguration(
2123
String servername, // "aem.servername"
2224
Integer port, // "aem.port"
@@ -26,7 +28,33 @@ public record AemConfiguration(
2628
@DefaultValue("aem") String sslBundle // "aem.sslBundle" - Spring SSL Bundle for trust store
2729
) {
2830

31+
public static final String CONFIGURATION_PREFIX = "fluentforms.aem";
32+
2933
public String url() {
30-
return "http" + (useSsl ? "s" : "") + "://" + servername + (port != null && port != 80 ? ":" + port : "") + "/";
34+
return "http" + (useSsl ? "s" : "") + "://" + (servername != null ? servername : "localhost") + (port != null && port != 80 ? ":" + port : "") + "/";
35+
}
36+
37+
public record Credentials(String user, String password) {}
38+
39+
public Optional<Credentials> getCredentials() {
40+
boolean hasUser = hasUser();
41+
boolean hasPassword = hasPassword();
42+
if (hasUser && hasPassword) {
43+
return Optional.of(new Credentials(user, password));
44+
} else if (!hasUser && !hasPassword) {
45+
return Optional.empty();
46+
} else if (hasUser) {
47+
throw new IllegalStateException("AEM user is specified but password is missing. (" + CONFIGURATION_PREFIX + ".password)");
48+
} else { /* must be hasPassword() */
49+
throw new IllegalStateException("AEM password is specified but user is missing. (" + CONFIGURATION_PREFIX + ".user)");
50+
}
51+
}
52+
53+
private boolean hasUser() {
54+
return user != null && !user.isBlank();
55+
}
56+
57+
private boolean hasPassword() {
58+
return password != null && !password.isBlank();
3159
}
3260
}

0 commit comments

Comments
 (0)