unfiltered) {
return mask.apply(unfiltered);
}
diff --git a/api/src/main/java/com/redhat/insights/InsightsCustomScheduledExecutor.java b/api/src/main/java/com/redhat/insights/InsightsCustomScheduledExecutor.java
index b5830881..ff816cca 100644
--- a/api/src/main/java/com/redhat/insights/InsightsCustomScheduledExecutor.java
+++ b/api/src/main/java/com/redhat/insights/InsightsCustomScheduledExecutor.java
@@ -8,8 +8,10 @@
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
+import org.jspecify.annotations.NullMarked;
/** A scheduler based on a single-threaded {@link ScheduledThreadPoolExecutor}. */
+@NullMarked
public class InsightsCustomScheduledExecutor extends ScheduledThreadPoolExecutor
implements InsightsScheduler {
private final InsightsLogger logger;
diff --git a/api/src/main/java/com/redhat/insights/InsightsErrorCode.java b/api/src/main/java/com/redhat/insights/InsightsErrorCode.java
index 2cfc6ab2..4f9f45d8 100644
--- a/api/src/main/java/com/redhat/insights/InsightsErrorCode.java
+++ b/api/src/main/java/com/redhat/insights/InsightsErrorCode.java
@@ -1,11 +1,14 @@
-/* Copyright (C) Red Hat 2022-2023 */
+/* Copyright (C) Red Hat 2022-2024 */
package com.redhat.insights;
+import org.jspecify.annotations.NullMarked;
+
/**
* Client internal errors.
*
* @author Emmanuel Hugonnet (c) 2023 Red Hat, Inc.
*/
+@NullMarked
public enum InsightsErrorCode {
NONE(0),
OPT_OUT(1),
diff --git a/api/src/main/java/com/redhat/insights/InsightsException.java b/api/src/main/java/com/redhat/insights/InsightsException.java
index 17627137..a58d8ef6 100644
--- a/api/src/main/java/com/redhat/insights/InsightsException.java
+++ b/api/src/main/java/com/redhat/insights/InsightsException.java
@@ -1,14 +1,17 @@
-/* Copyright (C) Red Hat 2023 */
+/* Copyright (C) Red Hat 2023-2024 */
package com.redhat.insights;
import static com.redhat.insights.InsightsErrorCode.NONE;
+import org.jspecify.annotations.NullMarked;
+
/**
* General-purpose insights client exception type.
*
* Lower-level exceptions (IO, etc.) shall be wrapped or attached to an {@link
* InsightsException}.
*/
+@NullMarked
public final class InsightsException extends RuntimeException {
private final InsightsErrorCode error;
@@ -42,6 +45,6 @@ public InsightsException(InsightsErrorCode error, Throwable cause) {
@Override
public String getMessage() {
- return error.formatMessage(super.getMessage());
+ return error.formatMessage(String.valueOf(super.getMessage()));
}
}
diff --git a/api/src/main/java/com/redhat/insights/InsightsReportController.java b/api/src/main/java/com/redhat/insights/InsightsReportController.java
index 381b9c1f..bb4754ae 100644
--- a/api/src/main/java/com/redhat/insights/InsightsReportController.java
+++ b/api/src/main/java/com/redhat/insights/InsightsReportController.java
@@ -16,6 +16,7 @@
import java.security.NoSuchAlgorithmException;
import java.util.concurrent.*;
import java.util.function.Supplier;
+import org.jspecify.annotations.NullMarked;
/**
* The controller class has primarily responsibility for managing the upload of {@code CONNECT} and
@@ -24,6 +25,7 @@
*
Client code must explicitly manage the lifecycle of the controller object, and shut it down at
* application exit.
*/
+@NullMarked
public final class InsightsReportController {
private final InsightsLogger logger;
diff --git a/api/src/main/java/com/redhat/insights/InsightsScheduler.java b/api/src/main/java/com/redhat/insights/InsightsScheduler.java
index fb28459b..ad8ec080 100644
--- a/api/src/main/java/com/redhat/insights/InsightsScheduler.java
+++ b/api/src/main/java/com/redhat/insights/InsightsScheduler.java
@@ -1,10 +1,12 @@
-/* Copyright (C) Red Hat 2023 */
+/* Copyright (C) Red Hat 2023-2024 */
package com.redhat.insights;
import java.util.List;
import java.util.concurrent.ScheduledFuture;
+import org.jspecify.annotations.NullMarked;
/** Interface for scheduling {@code CONNECT} and {@code UPDATE} events. */
+@NullMarked
public interface InsightsScheduler {
/**
diff --git a/api/src/main/java/com/redhat/insights/config/DefaultInsightsConfiguration.java b/api/src/main/java/com/redhat/insights/config/DefaultInsightsConfiguration.java
index 1287e21f..45e824ad 100644
--- a/api/src/main/java/com/redhat/insights/config/DefaultInsightsConfiguration.java
+++ b/api/src/main/java/com/redhat/insights/config/DefaultInsightsConfiguration.java
@@ -1,8 +1,11 @@
-/* Copyright (C) Red Hat 2023 */
+/* Copyright (C) Red Hat 2023-2024 */
package com.redhat.insights.config;
+import org.jspecify.annotations.NullMarked;
+
/**
* Base configuration that uses the default methods from {@link InsightsConfiguration}, and where
* only {@link InsightsConfiguration#getIdentificationName()} needs to be overridden.
*/
+@NullMarked
public abstract class DefaultInsightsConfiguration implements InsightsConfiguration {}
diff --git a/api/src/main/java/com/redhat/insights/config/EnvAndSysPropsInsightsConfiguration.java b/api/src/main/java/com/redhat/insights/config/EnvAndSysPropsInsightsConfiguration.java
index 5689d243..85feb0fb 100644
--- a/api/src/main/java/com/redhat/insights/config/EnvAndSysPropsInsightsConfiguration.java
+++ b/api/src/main/java/com/redhat/insights/config/EnvAndSysPropsInsightsConfiguration.java
@@ -6,6 +6,7 @@
import com.redhat.insights.InsightsException;
import java.time.Duration;
import java.util.Optional;
+import org.jspecify.annotations.NullMarked;
/**
* Configuration where values from {@link DefaultInsightsConfiguration} can be overridden by
@@ -13,6 +14,7 @@
*
*
Environment variables take priority over system properties.
*/
+@NullMarked
public class EnvAndSysPropsInsightsConfiguration extends DefaultInsightsConfiguration {
public static final String ENV_IDENTIFICATION_NAME = "RHT_INSIGHTS_JAVA_IDENTIFICATION_NAME";
diff --git a/api/src/main/java/com/redhat/insights/config/InsightsConfiguration.java b/api/src/main/java/com/redhat/insights/config/InsightsConfiguration.java
index 61f611e9..43eacf91 100644
--- a/api/src/main/java/com/redhat/insights/config/InsightsConfiguration.java
+++ b/api/src/main/java/com/redhat/insights/config/InsightsConfiguration.java
@@ -3,11 +3,13 @@
import java.time.Duration;
import java.util.Optional;
+import org.jspecify.annotations.NullMarked;
/**
* Insights client configuration, covering topics such as PEM file locations, endpoint parameters,
* proxing and more.
*/
+@NullMarked
public interface InsightsConfiguration {
String DEFAULT_RHEL_CERT_FILE_PATH = "/etc/pki/consumer/cert.pem";
diff --git a/api/src/main/java/com/redhat/insights/http/BackoffWrapper.java b/api/src/main/java/com/redhat/insights/http/BackoffWrapper.java
index 7bcc8cbd..72235f76 100644
--- a/api/src/main/java/com/redhat/insights/http/BackoffWrapper.java
+++ b/api/src/main/java/com/redhat/insights/http/BackoffWrapper.java
@@ -7,6 +7,7 @@
import com.redhat.insights.InsightsException;
import com.redhat.insights.config.InsightsConfiguration;
import com.redhat.insights.logging.InsightsLogger;
+import org.jspecify.annotations.NullMarked;
/**
* A general-purpose exponential backoff implementation.
@@ -14,6 +15,7 @@
*
It wraps an execution that might throw an exception (see {@link Action}). In this case
* attempts will be retried with the provided parameters (count, initial delay, factor).
*/
+@NullMarked
public final class BackoffWrapper {
@FunctionalInterface
diff --git a/api/src/main/java/com/redhat/insights/http/InsightsFileWritingClient.java b/api/src/main/java/com/redhat/insights/http/InsightsFileWritingClient.java
index 0b095bfd..d3a93f0f 100644
--- a/api/src/main/java/com/redhat/insights/http/InsightsFileWritingClient.java
+++ b/api/src/main/java/com/redhat/insights/http/InsightsFileWritingClient.java
@@ -14,7 +14,10 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
+import org.jspecify.annotations.NullMarked;
+/** A client that writes the insights report to a file. */
+@NullMarked
public class InsightsFileWritingClient implements InsightsHttpClient {
private final InsightsLogger logger;
private final InsightsConfiguration config;
diff --git a/api/src/main/java/com/redhat/insights/http/InsightsHttpClient.java b/api/src/main/java/com/redhat/insights/http/InsightsHttpClient.java
index d42055c4..75c3e3a6 100644
--- a/api/src/main/java/com/redhat/insights/http/InsightsHttpClient.java
+++ b/api/src/main/java/com/redhat/insights/http/InsightsHttpClient.java
@@ -1,4 +1,4 @@
-/* Copyright (C) Red Hat 2023 */
+/* Copyright (C) Red Hat 2023-2024 */
package com.redhat.insights.http;
import static com.redhat.insights.InsightsErrorCode.ERROR_GZIP_FILE;
@@ -8,7 +8,9 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
import java.util.zip.GZIPOutputStream;
+import org.jspecify.annotations.NullMarked;
/**
* The main interface used for delivering Insights data (aka archives) to Red Hat. Note that the
@@ -16,6 +18,7 @@
* However, we need to also support a file-based mechanism - but only temporarily - so we don't warp
* the interface name.
*/
+@NullMarked
public interface InsightsHttpClient {
public static final String GENERAL_MIME_TYPE =
@@ -72,7 +75,8 @@ static byte[] gzipReport(final byte[] report) {
gzip.close();
return baos.toByteArray();
} catch (IOException iox) {
- throw new InsightsException(ERROR_GZIP_FILE, "Failed to GZIP report: " + report, iox);
+ throw new InsightsException(
+ ERROR_GZIP_FILE, "Failed to GZIP report: " + Arrays.toString(report), iox);
}
}
}
diff --git a/api/src/main/java/com/redhat/insights/http/InsightsMultiClient.java b/api/src/main/java/com/redhat/insights/http/InsightsMultiClient.java
index aeff4522..ffb0ed95 100644
--- a/api/src/main/java/com/redhat/insights/http/InsightsMultiClient.java
+++ b/api/src/main/java/com/redhat/insights/http/InsightsMultiClient.java
@@ -1,4 +1,4 @@
-/* Copyright (C) Red Hat 2023 */
+/* Copyright (C) Red Hat 2023-2024 */
package com.redhat.insights.http;
import static com.redhat.insights.InsightsErrorCode.ERROR_CLIENT_FAILED;
@@ -8,11 +8,13 @@
import com.redhat.insights.reports.InsightsReport;
import java.util.Arrays;
import java.util.List;
+import org.jspecify.annotations.NullMarked;
/**
* An implementation of the Insights client interface that can try multiple connection paths. This
* includes the expected primary use case of HTTPS, then File.
*/
+@NullMarked
public class InsightsMultiClient implements InsightsHttpClient {
private final InsightsLogger logger;
private final List clients;
diff --git a/api/src/main/java/com/redhat/insights/jars/JarAnalyzer.java b/api/src/main/java/com/redhat/insights/jars/JarAnalyzer.java
index f4190106..4b957516 100644
--- a/api/src/main/java/com/redhat/insights/jars/JarAnalyzer.java
+++ b/api/src/main/java/com/redhat/insights/jars/JarAnalyzer.java
@@ -138,21 +138,20 @@ private JarInfo getJarInfo(String jarFilename, URL url, Map attr
try {
getExtraAttributes(jarInputStream, attributes);
- Map pom = getPom(jarInputStream);
+ Optional