Skip to content

Commit 8138f46

Browse files
authored
fix: Remove org.jspecify dependency (#1364)
1 parent 31b23c3 commit 8138f46

11 files changed

+17
-32
lines changed

google-cloud-logging/pom.xml

-5
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,6 @@
9090
<groupId>com.google.cloud</groupId>
9191
<artifactId>google-cloud-core</artifactId>
9292
</dependency>
93-
<dependency>
94-
<groupId>org.jspecify</groupId>
95-
<artifactId>jspecify</artifactId>
96-
<version>0.2.0</version>
97-
</dependency>
9893
<dependency>
9994
<groupId>com.google.errorprone</groupId>
10095
<artifactId>error_prone_annotations</artifactId>

google-cloud-logging/src/main/java/com/google/cloud/logging/Instrumentation.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import java.util.ArrayList;
3030
import java.util.Collections;
3131
import java.util.List;
32-
import org.jspecify.nullness.Nullable;
3332

3433
public final class Instrumentation {
3534
public static final String DIAGNOSTIC_INFO_KEY = "logging.googleapis.com/diagnostic";
@@ -103,7 +102,7 @@ public static Tuple<Boolean, Iterable<LogEntry>> populateInstrumentationInfo(
103102
* @return The new array of oprions containing WriteOption.OptionType.PARTIAL_SUCCESS flag set to
104103
* true
105104
*/
106-
public static WriteOption @Nullable [] addPartialSuccessOption(WriteOption[] options) {
105+
public static WriteOption[] addPartialSuccessOption(WriteOption[] options) {
107106
if (options == null) {
108107
return options;
109108
}

google-cloud-logging/src/main/java/com/google/cloud/logging/LogDestinationName.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
import com.google.logging.v2.LogName;
2323
import java.util.Map;
24-
import org.jspecify.nullness.Nullable;
2524

2625
/**
2726
* 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) {
8887
}
8988

9089
/** Creates a {@code LogEntry} object for given log ID. */
91-
public @Nullable LogName toLogName(String logId) {
90+
public LogName toLogName(String logId) {
9291
if (logId == null) {
9392
return null;
9493
}
@@ -121,7 +120,7 @@ public DestinationType getDestinationType() {
121120
}
122121

123122
/** Creates a {@code LogDestinationName} object from given {@code LogName}. */
124-
public static @Nullable LogDestinationName fromLogName(LogName logName) {
123+
public static LogDestinationName fromLogName(LogName logName) {
125124
if (logName == null) {
126125
return null;
127126
}

google-cloud-logging/src/main/java/com/google/cloud/logging/LogEntry.java

+4-5
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
import java.util.HashMap;
3939
import java.util.Map;
4040
import java.util.Objects;
41-
import org.jspecify.nullness.Nullable;
4241

4342
/**
4443
* A Cloud Logging log entry. All log entries are represented via objects of this class. Log entries
@@ -369,7 +368,7 @@ public MonitoredResource getResource() {
369368
* @return timestamp in milliseconds
370369
*/
371370
@Deprecated
372-
public @Nullable Long getTimestamp() {
371+
public Long getTimestamp() {
373372
return timestamp != null ? timestamp.toEpochMilli() : null;
374373
}
375374

@@ -390,7 +389,7 @@ public Instant getInstantTimestamp() {
390389
* @return timestamp in milliseconds
391390
*/
392391
@Deprecated
393-
public @Nullable Long getReceiveTimestamp() {
392+
public Long getReceiveTimestamp() {
394393
return receiveTimestamp != null ? receiveTimestamp.toEpochMilli() : null;
395394
}
396395

@@ -438,13 +437,13 @@ public Operation getOperation() {
438437
* Returns the resource name of the trace associated with the log entry, if any. If it contains a
439438
* relative resource name, the name is assumed to be relative to `//tracing.googleapis.com`.
440439
*/
441-
public @Nullable String getTrace() {
440+
public String getTrace() {
442441
// For backwards compatibility return null when trace not set instead of "null".
443442
return trace == null ? null : trace;
444443
}
445444

446445
/** Returns the ID of the trace span associated with the log entry, if any. */
447-
public @Nullable String getSpanId() {
446+
public String getSpanId() {
448447
// For backwards compatibility return null when spanId not set instead of "null".
449448
return spanId == null ? null : spanId;
450449
}

google-cloud-logging/src/main/java/com/google/cloud/logging/LoggingHandler.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
import java.util.logging.LogRecord;
3737
import java.util.logging.Logger;
3838
import java.util.logging.SimpleFormatter;
39-
import org.jspecify.nullness.Nullable;
4039

4140
/**
4241
* A logging handler that outputs logs generated with {@link java.util.logging.Logger} to Cloud
@@ -356,7 +355,7 @@ public void publish(LogRecord record) {
356355
}
357356
}
358357

359-
private @Nullable MonitoredResource getMonitoredResource() {
358+
private MonitoredResource getMonitoredResource() {
360359
Optional<WriteOption> resourceOption =
361360
stream(defaultWriteOptions)
362361
.filter(o -> o.getOptionType() == WriteOption.OptionType.RESOURCE)

google-cloud-logging/src/main/java/com/google/cloud/logging/LoggingImpl.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@
9898
import java.util.concurrent.ExecutionException;
9999
import java.util.concurrent.TimeUnit;
100100
import java.util.concurrent.TimeoutException;
101-
import org.jspecify.nullness.Nullable;
102101

103102
class LoggingImpl extends BaseService<LoggingOptions> implements Logging {
104103
protected static final String RESOURCE_NAME_FORMAT = "projects/%s/traces/%s";
@@ -791,7 +790,7 @@ private static WriteLogEntriesRequest writeLogEntriesRequest(
791790
return builder.build();
792791
}
793792

794-
private static @Nullable LogName getLogName(
793+
private static LogName getLogName(
795794
String projectId, String logName, LogDestinationName destination) {
796795
if (logName == null) {
797796
return null;
@@ -921,7 +920,7 @@ public void flush() {
921920
* @param resource A {@see MonitoredResource} describing environment metadata.
922921
* @return A formatted trace id string.
923922
*/
924-
private @Nullable String getFormattedTrace(String traceId, MonitoredResource resource) {
923+
private String getFormattedTrace(String traceId, MonitoredResource resource) {
925924
if (traceId == null) {
926925
return null;
927926
}

google-cloud-logging/src/main/java/com/google/cloud/logging/MetadataLoader.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import java.nio.file.Files;
2525
import java.nio.file.Paths;
2626
import java.util.function.Supplier;
27-
import org.jspecify.nullness.Nullable;
2827

2928
public final class MetadataLoader {
3029
public static final String ENV_FLEXIBLE = "flex";
@@ -64,7 +63,7 @@ public MetadataLoader(ResourceTypeEnvironmentGetter getter) {
6463
* @param label A resource metadata label of type {@see MonitoredResourceUtil.Label}
6564
* @return A string with metadata value or {@code null} if the label is not supported.
6665
*/
67-
public @Nullable String getValue(MonitoredResourceUtil.Label label) {
66+
public String getValue(MonitoredResourceUtil.Label label) {
6867
Supplier<String> lambda = labelResolvers.get(label);
6968
if (lambda != null) {
7069
return lambda.get();
@@ -175,7 +174,7 @@ private String getProjectId() {
175174
*
176175
* @return region string id
177176
*/
178-
private @Nullable String getRegion() {
177+
private String getRegion() {
179178
String loc = getter.getAttribute("instance/region");
180179
if (loc != null) {
181180
return loc.substring(loc.lastIndexOf('/') + 1);
@@ -199,7 +198,7 @@ private String getVersionId() {
199198
*
200199
* @return zone string id
201200
*/
202-
private @Nullable String getZone() {
201+
private String getZone() {
203202
String loc = getter.getAttribute("instance/zone");
204203
if (loc != null) {
205204
return loc.substring(loc.lastIndexOf('/') + 1);

google-cloud-logging/src/main/java/com/google/cloud/logging/ResourceTypeEnvironmentGetterImpl.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@
1717
package com.google.cloud.logging;
1818

1919
import com.google.cloud.MetadataConfig;
20-
import org.jspecify.nullness.Nullable;
2120

2221
final class ResourceTypeEnvironmentGetterImpl implements ResourceTypeEnvironmentGetter {
2322

2423
@Override
25-
public @Nullable String getEnv(String name) {
24+
public String getEnv(String name) {
2625
// handle exception thrown if a security manager exists and blocks access to the
2726
// process environment
2827
try {

google-cloud-logging/src/main/java/com/google/cloud/logging/SinkInfo.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import java.util.Objects;
2626
import java.util.regex.Matcher;
2727
import java.util.regex.Pattern;
28-
import org.jspecify.nullness.Nullable;
2928

3029
/**
3130
* Cloud Logging sinks can be used to control the export of your logs. Each sink specifies the
@@ -478,7 +477,7 @@ LogSink.VersionFormat toPb() {
478477
return versionPb;
479478
}
480479

481-
static @Nullable VersionFormat fromPb(LogSink.VersionFormat versionPb) {
480+
static VersionFormat fromPb(LogSink.VersionFormat versionPb) {
482481
switch (versionPb) {
483482
case V1:
484483
return VersionFormat.V1;

google-cloud-logging/src/main/java/com/google/cloud/logging/SourceLocation.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import com.google.logging.v2.LogEntrySourceLocation;
2525
import java.io.Serializable;
2626
import java.util.Objects;
27-
import org.jspecify.nullness.Nullable;
2827

2928
/** Additional information about the source code location that produced the log entry. */
3029
public final class SourceLocation implements Serializable {
@@ -174,7 +173,7 @@ static SourceLocation fromPb(LogEntrySourceLocation sourceLocationPb) {
174173
* @return a new instance of {@link SourceLocation} populated with file name, method and line
175174
* number information.
176175
*/
177-
static @Nullable SourceLocation fromCurrentContext(String... exclusionClassPaths) {
176+
static SourceLocation fromCurrentContext(String... exclusionClassPaths) {
178177
StackTraceElement[] stackTrace = new Exception().getStackTrace();
179178

180179
for (int level = 1; level < stackTrace.length; level++) {

google-cloud-logging/src/main/java/com/google/cloud/logging/Structs.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import java.util.Iterator;
3333
import java.util.Map;
3434
import java.util.Set;
35-
import org.jspecify.nullness.Nullable;
3635

3736
/**
3837
* This class contains static utility methods that operate on or return protobuf's {@code Struct}
@@ -101,7 +100,7 @@ static Struct newStruct(Map<String, ?> map) {
101100
return Struct.newBuilder().putAllFields(valueMap).build();
102101
}
103102

104-
private static @Nullable Object valueToObject(Value value) {
103+
private static Object valueToObject(Value value) {
105104
switch (value.getKindCase()) {
106105
case NULL_VALUE:
107106
return null;

0 commit comments

Comments
 (0)