From fa42b9f72b969e01200bd92a4f318c4da3c5155c Mon Sep 17 00:00:00 2001 From: losalex Date: Tue, 6 Jun 2023 10:31:21 -0700 Subject: [PATCH] fix: Remove org.jspecify dependency --- google-cloud-logging/pom.xml | 5 ----- .../java/com/google/cloud/logging/Instrumentation.java | 3 +-- .../com/google/cloud/logging/LogDestinationName.java | 5 ++--- .../src/main/java/com/google/cloud/logging/LogEntry.java | 9 ++++----- .../java/com/google/cloud/logging/LoggingHandler.java | 3 +-- .../main/java/com/google/cloud/logging/LoggingImpl.java | 5 ++--- .../java/com/google/cloud/logging/MetadataLoader.java | 7 +++---- .../cloud/logging/ResourceTypeEnvironmentGetterImpl.java | 3 +-- .../src/main/java/com/google/cloud/logging/SinkInfo.java | 3 +-- .../java/com/google/cloud/logging/SourceLocation.java | 3 +-- .../src/main/java/com/google/cloud/logging/Structs.java | 3 +-- 11 files changed, 17 insertions(+), 32 deletions(-) diff --git a/google-cloud-logging/pom.xml b/google-cloud-logging/pom.xml index 2277b1cae..c2fe564cf 100644 --- a/google-cloud-logging/pom.xml +++ b/google-cloud-logging/pom.xml @@ -90,11 +90,6 @@ com.google.cloud google-cloud-core - - org.jspecify - jspecify - 0.2.0 - com.google.errorprone error_prone_annotations diff --git a/google-cloud-logging/src/main/java/com/google/cloud/logging/Instrumentation.java b/google-cloud-logging/src/main/java/com/google/cloud/logging/Instrumentation.java index 6e5bb8707..c6e97551a 100644 --- a/google-cloud-logging/src/main/java/com/google/cloud/logging/Instrumentation.java +++ b/google-cloud-logging/src/main/java/com/google/cloud/logging/Instrumentation.java @@ -29,7 +29,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import org.jspecify.nullness.Nullable; public final class Instrumentation { public static final String DIAGNOSTIC_INFO_KEY = "logging.googleapis.com/diagnostic"; @@ -103,7 +102,7 @@ public static Tuple> populateInstrumentationInfo( * @return The new array of oprions containing WriteOption.OptionType.PARTIAL_SUCCESS flag set to * true */ - public static WriteOption @Nullable [] addPartialSuccessOption(WriteOption[] options) { + public static WriteOption[] addPartialSuccessOption(WriteOption[] options) { if (options == null) { return options; } diff --git a/google-cloud-logging/src/main/java/com/google/cloud/logging/LogDestinationName.java b/google-cloud-logging/src/main/java/com/google/cloud/logging/LogDestinationName.java index 089db8f7e..dcf6a12cc 100644 --- a/google-cloud-logging/src/main/java/com/google/cloud/logging/LogDestinationName.java +++ b/google-cloud-logging/src/main/java/com/google/cloud/logging/LogDestinationName.java @@ -21,7 +21,6 @@ import com.google.logging.v2.LogName; import java.util.Map; -import org.jspecify.nullness.Nullable; /** * Class for specifying resource name of the log to which this log entry belongs (see 'logName' @@ -88,7 +87,7 @@ public static LogDestinationName billingAccount(String id) { } /** Creates a {@code LogEntry} object for given log ID. */ - public @Nullable LogName toLogName(String logId) { + public LogName toLogName(String logId) { if (logId == null) { return null; } @@ -121,7 +120,7 @@ public DestinationType getDestinationType() { } /** Creates a {@code LogDestinationName} object from given {@code LogName}. */ - public static @Nullable LogDestinationName fromLogName(LogName logName) { + public static LogDestinationName fromLogName(LogName logName) { if (logName == null) { return null; } diff --git a/google-cloud-logging/src/main/java/com/google/cloud/logging/LogEntry.java b/google-cloud-logging/src/main/java/com/google/cloud/logging/LogEntry.java index 5c5727d27..72622031d 100644 --- a/google-cloud-logging/src/main/java/com/google/cloud/logging/LogEntry.java +++ b/google-cloud-logging/src/main/java/com/google/cloud/logging/LogEntry.java @@ -38,7 +38,6 @@ import java.util.HashMap; import java.util.Map; import java.util.Objects; -import org.jspecify.nullness.Nullable; /** * A Cloud Logging log entry. All log entries are represented via objects of this class. Log entries @@ -369,7 +368,7 @@ public MonitoredResource getResource() { * @return timestamp in milliseconds */ @Deprecated - public @Nullable Long getTimestamp() { + public Long getTimestamp() { return timestamp != null ? timestamp.toEpochMilli() : null; } @@ -390,7 +389,7 @@ public Instant getInstantTimestamp() { * @return timestamp in milliseconds */ @Deprecated - public @Nullable Long getReceiveTimestamp() { + public Long getReceiveTimestamp() { return receiveTimestamp != null ? receiveTimestamp.toEpochMilli() : null; } @@ -438,13 +437,13 @@ public Operation getOperation() { * Returns the resource name of the trace associated with the log entry, if any. If it contains a * relative resource name, the name is assumed to be relative to `//tracing.googleapis.com`. */ - public @Nullable String getTrace() { + public String getTrace() { // For backwards compatibility return null when trace not set instead of "null". return trace == null ? null : trace; } /** Returns the ID of the trace span associated with the log entry, if any. */ - public @Nullable String getSpanId() { + public String getSpanId() { // For backwards compatibility return null when spanId not set instead of "null". return spanId == null ? null : spanId; } diff --git a/google-cloud-logging/src/main/java/com/google/cloud/logging/LoggingHandler.java b/google-cloud-logging/src/main/java/com/google/cloud/logging/LoggingHandler.java index a0b176968..2e1fd9d8b 100644 --- a/google-cloud-logging/src/main/java/com/google/cloud/logging/LoggingHandler.java +++ b/google-cloud-logging/src/main/java/com/google/cloud/logging/LoggingHandler.java @@ -36,7 +36,6 @@ import java.util.logging.LogRecord; import java.util.logging.Logger; import java.util.logging.SimpleFormatter; -import org.jspecify.nullness.Nullable; /** * A logging handler that outputs logs generated with {@link java.util.logging.Logger} to Cloud @@ -356,7 +355,7 @@ public void publish(LogRecord record) { } } - private @Nullable MonitoredResource getMonitoredResource() { + private MonitoredResource getMonitoredResource() { Optional resourceOption = stream(defaultWriteOptions) .filter(o -> o.getOptionType() == WriteOption.OptionType.RESOURCE) diff --git a/google-cloud-logging/src/main/java/com/google/cloud/logging/LoggingImpl.java b/google-cloud-logging/src/main/java/com/google/cloud/logging/LoggingImpl.java index 48aca324c..d1e3b0ae9 100644 --- a/google-cloud-logging/src/main/java/com/google/cloud/logging/LoggingImpl.java +++ b/google-cloud-logging/src/main/java/com/google/cloud/logging/LoggingImpl.java @@ -98,7 +98,6 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import org.jspecify.nullness.Nullable; class LoggingImpl extends BaseService implements Logging { protected static final String RESOURCE_NAME_FORMAT = "projects/%s/traces/%s"; @@ -791,7 +790,7 @@ private static WriteLogEntriesRequest writeLogEntriesRequest( return builder.build(); } - private static @Nullable LogName getLogName( + private static LogName getLogName( String projectId, String logName, LogDestinationName destination) { if (logName == null) { return null; @@ -921,7 +920,7 @@ public void flush() { * @param resource A {@see MonitoredResource} describing environment metadata. * @return A formatted trace id string. */ - private @Nullable String getFormattedTrace(String traceId, MonitoredResource resource) { + private String getFormattedTrace(String traceId, MonitoredResource resource) { if (traceId == null) { return null; } diff --git a/google-cloud-logging/src/main/java/com/google/cloud/logging/MetadataLoader.java b/google-cloud-logging/src/main/java/com/google/cloud/logging/MetadataLoader.java index 7e2e74f1d..1a0581626 100644 --- a/google-cloud-logging/src/main/java/com/google/cloud/logging/MetadataLoader.java +++ b/google-cloud-logging/src/main/java/com/google/cloud/logging/MetadataLoader.java @@ -24,7 +24,6 @@ import java.nio.file.Files; import java.nio.file.Paths; import java.util.function.Supplier; -import org.jspecify.nullness.Nullable; public final class MetadataLoader { public static final String ENV_FLEXIBLE = "flex"; @@ -64,7 +63,7 @@ public MetadataLoader(ResourceTypeEnvironmentGetter getter) { * @param label A resource metadata label of type {@see MonitoredResourceUtil.Label} * @return A string with metadata value or {@code null} if the label is not supported. */ - public @Nullable String getValue(MonitoredResourceUtil.Label label) { + public String getValue(MonitoredResourceUtil.Label label) { Supplier lambda = labelResolvers.get(label); if (lambda != null) { return lambda.get(); @@ -175,7 +174,7 @@ private String getProjectId() { * * @return region string id */ - private @Nullable String getRegion() { + private String getRegion() { String loc = getter.getAttribute("instance/region"); if (loc != null) { return loc.substring(loc.lastIndexOf('/') + 1); @@ -199,7 +198,7 @@ private String getVersionId() { * * @return zone string id */ - private @Nullable String getZone() { + private String getZone() { String loc = getter.getAttribute("instance/zone"); if (loc != null) { return loc.substring(loc.lastIndexOf('/') + 1); diff --git a/google-cloud-logging/src/main/java/com/google/cloud/logging/ResourceTypeEnvironmentGetterImpl.java b/google-cloud-logging/src/main/java/com/google/cloud/logging/ResourceTypeEnvironmentGetterImpl.java index fd546aa88..2ee3a3eae 100644 --- a/google-cloud-logging/src/main/java/com/google/cloud/logging/ResourceTypeEnvironmentGetterImpl.java +++ b/google-cloud-logging/src/main/java/com/google/cloud/logging/ResourceTypeEnvironmentGetterImpl.java @@ -17,12 +17,11 @@ package com.google.cloud.logging; import com.google.cloud.MetadataConfig; -import org.jspecify.nullness.Nullable; final class ResourceTypeEnvironmentGetterImpl implements ResourceTypeEnvironmentGetter { @Override - public @Nullable String getEnv(String name) { + public String getEnv(String name) { // handle exception thrown if a security manager exists and blocks access to the // process environment try { diff --git a/google-cloud-logging/src/main/java/com/google/cloud/logging/SinkInfo.java b/google-cloud-logging/src/main/java/com/google/cloud/logging/SinkInfo.java index b2a9bb97d..872db32b1 100644 --- a/google-cloud-logging/src/main/java/com/google/cloud/logging/SinkInfo.java +++ b/google-cloud-logging/src/main/java/com/google/cloud/logging/SinkInfo.java @@ -25,7 +25,6 @@ import java.util.Objects; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.jspecify.nullness.Nullable; /** * Cloud Logging sinks can be used to control the export of your logs. Each sink specifies the @@ -478,7 +477,7 @@ LogSink.VersionFormat toPb() { return versionPb; } - static @Nullable VersionFormat fromPb(LogSink.VersionFormat versionPb) { + static VersionFormat fromPb(LogSink.VersionFormat versionPb) { switch (versionPb) { case V1: return VersionFormat.V1; diff --git a/google-cloud-logging/src/main/java/com/google/cloud/logging/SourceLocation.java b/google-cloud-logging/src/main/java/com/google/cloud/logging/SourceLocation.java index 966ea63ef..1099fd285 100644 --- a/google-cloud-logging/src/main/java/com/google/cloud/logging/SourceLocation.java +++ b/google-cloud-logging/src/main/java/com/google/cloud/logging/SourceLocation.java @@ -24,7 +24,6 @@ import com.google.logging.v2.LogEntrySourceLocation; import java.io.Serializable; import java.util.Objects; -import org.jspecify.nullness.Nullable; /** Additional information about the source code location that produced the log entry. */ public final class SourceLocation implements Serializable { @@ -174,7 +173,7 @@ static SourceLocation fromPb(LogEntrySourceLocation sourceLocationPb) { * @return a new instance of {@link SourceLocation} populated with file name, method and line * number information. */ - static @Nullable SourceLocation fromCurrentContext(String... exclusionClassPaths) { + static SourceLocation fromCurrentContext(String... exclusionClassPaths) { StackTraceElement[] stackTrace = new Exception().getStackTrace(); for (int level = 1; level < stackTrace.length; level++) { diff --git a/google-cloud-logging/src/main/java/com/google/cloud/logging/Structs.java b/google-cloud-logging/src/main/java/com/google/cloud/logging/Structs.java index 884e6ff08..46ba567e6 100644 --- a/google-cloud-logging/src/main/java/com/google/cloud/logging/Structs.java +++ b/google-cloud-logging/src/main/java/com/google/cloud/logging/Structs.java @@ -32,7 +32,6 @@ import java.util.Iterator; import java.util.Map; import java.util.Set; -import org.jspecify.nullness.Nullable; /** * This class contains static utility methods that operate on or return protobuf's {@code Struct} @@ -101,7 +100,7 @@ static Struct newStruct(Map map) { return Struct.newBuilder().putAllFields(valueMap).build(); } - private static @Nullable Object valueToObject(Value value) { + private static Object valueToObject(Value value) { switch (value.getKindCase()) { case NULL_VALUE: return null;