Skip to content

Commit e9dacac

Browse files
authored
Move JSpecify annotations closest to the target and enable NullAway annotation check (#39)
* update to Quarkus 3.32.1 and update dependencies to latest versions * validate K8s resource references against the RFC 1123 hostname format Kubernetes uses * refactor SecretRef and ClusterReference to one common ResourceRef type * fix the test by having a own SchemaCustomizer for Kubernetes names * do not short-circuit the PostgreSQLInstanceReadinessCheck check once one instance is down * let the PostgreSQLContextFactory exception bubble up * reformat code * fix compile issue * move the JSpecify annotations closest to their target * enable NullAway option RequireExplicitNullMarking to detect classes that are not annotated with JSpecify annotations * the namespace should come always first * add explicit string max length check of 63 * add explicit string max length check of 63
1 parent 5e75443 commit e9dacac

53 files changed

Lines changed: 131 additions & 186 deletions

Some content is hidden

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

build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ subprojects {
8383

8484
options.errorprone {
8585
check("NullAway", CheckSeverity.ERROR)
86+
check("RequireExplicitNullMarking", CheckSeverity.ERROR)
8687
option("NullAway:AnnotatedPackages", "it.aboutbits.postgresql")
8788
option("NullAway:JSpecifyMode", "true")
8889
}

operator/src/main/java/it/aboutbits/postgresql/PostgreSQLInstanceReadinessCheck.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
* configured PostgreSQL instances. Each instance is probed with a lightweight
1616
* operation, and the aggregated status is exposed.
1717
*/
18-
@NullMarked
1918
@Readiness
2019
@RequiredArgsConstructor
20+
@NullMarked
2121
public class PostgreSQLInstanceReadinessCheck implements HealthCheck {
2222
private final PostgreSQLContextFactory postgreSQLContextFactory;
2323

operator/src/main/java/it/aboutbits/postgresql/core/BaseReconciler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
import java.util.Optional;
1515
import java.util.concurrent.TimeUnit;
1616

17-
@NullMarked
1817
@Slf4j
18+
@NullMarked
1919
public abstract class BaseReconciler<CR extends CustomResource<?, S> & Named, S extends CRStatus> {
2020
protected abstract S newStatus();
2121

operator/src/main/java/it/aboutbits/postgresql/core/CRStatus.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,15 @@
1515
* <p>
1616
* This object captures the current state of a Custom Resource as observed by the reconciler.
1717
*/
18-
@NullMarked
1918
@Getter
2019
@Setter
2120
@Accessors(chain = true)
21+
@NullMarked
2222
public class CRStatus {
2323
/**
2424
* The Custom Resource name (may differ from metadata.name).
2525
*/
26-
@Nullable
27-
private String name = null;
26+
private @Nullable String name = null;
2827

2928
/**
3029
* Current lifecycle phase of the Bucket.
@@ -35,21 +34,18 @@ public class CRStatus {
3534
/**
3635
* Human-readable message providing details about the current state.
3736
*/
38-
@Nullable
39-
private String message = null;
37+
private @Nullable String message = null;
4038

4139
/**
4240
* Last time the condition was probed/updated.
4341
*/
44-
@Nullable
45-
private OffsetDateTime lastProbeTime = null;
42+
private @Nullable OffsetDateTime lastProbeTime = null;
4643

4744
/**
4845
* Last time the condition transitioned from one status to another.
4946
*/
50-
@Nullable
5147
@Setter(AccessLevel.NONE)
52-
private OffsetDateTime lastPhaseTransitionTime = null;
48+
private @Nullable OffsetDateTime lastPhaseTransitionTime = null;
5349

5450
/**
5551
* Observed resource generation that the controller acted upon.

operator/src/main/java/it/aboutbits/postgresql/core/KubernetesService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
import java.nio.charset.Charset;
99
import java.util.Base64;
1010

11-
@NullMarked
1211
@Singleton
12+
@NullMarked
1313
public final class KubernetesService {
1414
public static final String SECRET_TYPE_BASIC_AUTH = "kubernetes.io/basic-auth";
1515
public static final String SECRET_DATA_BASIC_AUTH_USERNAME_KEY = "username";

operator/src/main/java/it/aboutbits/postgresql/core/PostgreSQLAuthenticationService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121

2222
import static it.aboutbits.postgresql.core.infrastructure.persistence.Tables.PG_AUTHID;
2323

24-
@NullMarked
2524
@Slf4j
2625
@Singleton
26+
@NullMarked
2727
public final class PostgreSQLAuthenticationService {
2828
private static final String MD5 = "MD5";
2929
private static final String SHA_256 = "SHA-256";

operator/src/main/java/it/aboutbits/postgresql/core/PostgreSQLContextFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111

1212
import java.util.Properties;
1313

14-
@NullMarked
1514
@ApplicationScoped
1615
@RequiredArgsConstructor
16+
@NullMarked
1717
public class PostgreSQLContextFactory {
1818
private static final String POSTGRESQL_AUTHENTICATION_USER_KEY = "user";
1919
private static final String POSTGRESQL_AUTHENTICATION_PASSWORD_KEY = "password";

operator/src/main/java/it/aboutbits/postgresql/core/Privilege.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
* https://www.postgresql.org/docs/current/sql-grant.html
1616
* </a>
1717
*/
18-
@NullMarked
1918
@Getter
2019
@Accessors(fluent = true)
2120
@RequiredArgsConstructor
21+
@NullMarked
2222
public enum Privilege {
2323
SELECT(null),
2424
INSERT(null),
@@ -33,8 +33,7 @@ public enum Privilege {
3333
USAGE(null),
3434
MAINTAIN(17);
3535

36-
@Nullable
37-
private final Integer minimumPostgresVersion;
36+
private final @Nullable Integer minimumPostgresVersion;
3837

3938
@JsonValue
4039
public String toValue() {

operator/src/main/java/it/aboutbits/postgresql/core/ReclaimPolicy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
import lombok.RequiredArgsConstructor;
55
import org.jspecify.annotations.NullMarked;
66

7-
@NullMarked
87
@RequiredArgsConstructor
8+
@NullMarked
99
public enum ReclaimPolicy {
1010
RETAIN("Retain"),
1111
DELETE("Delete");

operator/src/main/java/it/aboutbits/postgresql/core/ResourceRef.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,16 @@
2626
/// |-------------------|-----------------------------------------------------|
2727
/// | non-null | the explicit namespace |
2828
/// | `null` (omitted) | the namespace of the CR that owns this reference |
29-
@NullMarked
3029
@Getter
3130
@Setter
3231
@SchemaCustomizer(KubernetesNameCustomizer.class)
32+
@NullMarked
3333
public class ResourceRef {
3434
/// The namespace of the referenced Kubernetes resource.
3535
/// If `null`, defaults to the namespace of the CR that defines this reference.
36-
@Nullable
37-
@Max(63)
3836
@io.fabric8.generator.annotation.Nullable
39-
private String namespace;
37+
@Max(63)
38+
private @Nullable String namespace;
4039

4140
@Required
4241
@Max(63)

0 commit comments

Comments
 (0)