Skip to content

Commit fef4772

Browse files
committed
fix(core): Resolve the remaining Error Prone and javac 21 findings in the sentry module
1 parent aaa1ef0 commit fef4772

21 files changed

Lines changed: 44 additions & 32 deletions

‎sentry/src/main/java/io/sentry/CombinedContextsView.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ public void setSpring(@NotNull Spring spring) {
243243

244244
@ApiStatus.Internal
245245
@Override
246-
/** Not intended to be set on a scopes Context directly */
246+
/* Not intended to be set on a scopes Context directly */
247247
public void setFeatureFlags(@NotNull FeatureFlags spring) {
248248
getDefaultContexts().setFeatureFlags(spring);
249249
}

‎sentry/src/main/java/io/sentry/DateUtils.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,10 @@ public static double nanosToSeconds(final long nanos) {
151151
*/
152152
@SuppressWarnings("JavaUtilDate")
153153
public static double dateToSeconds(final @NotNull Date date) {
154-
return millisToSeconds(date.getTime());
154+
return millisToSeconds((double) date.getTime());
155155
}
156156

157-
public static long secondsToNanos(final @NotNull long seconds) {
157+
public static long secondsToNanos(final long seconds) {
158158
return seconds * (1000L * 1000L * 1000L);
159159
}
160160

‎sentry/src/main/java/io/sentry/DefaultSpanFactory.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public final class DefaultSpanFactory implements ISpanFactory {
2121
final @NotNull SpanOptions spanOptions,
2222
final @NotNull SpanContext spanContext,
2323
@Nullable ISpan parentSpan) {
24-
/**
24+
/*
2525
* Be careful here when executing something like parentSpan.startChild() as that might cause a
2626
* loop and a stack overflow. This can happen, e.g. when OpenTelemetry is creating spans that
2727
* use OtelSpanWrapper which calls this createSpan method that then in turn calls startChild

‎sentry/src/main/java/io/sentry/DirectoryProcessor.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ private static final class SendCachedEnvelopeHint
120120
private final @NotNull String filePath;
121121
private final @NotNull Queue<String> processedEnvelopes;
122122

123-
public SendCachedEnvelopeHint(
123+
SendCachedEnvelopeHint(
124124
final long flushTimeoutMillis,
125125
final @NotNull ILogger logger,
126126
final @NotNull String filePath,

‎sentry/src/main/java/io/sentry/ExternalOptions.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,8 @@ public final class ExternalOptions {
242242

243243
String profileLifecycleString = propertiesProvider.getProperty("profile-lifecycle");
244244
if (profileLifecycleString != null && !profileLifecycleString.isEmpty()) {
245-
options.setProfileLifecycle(ProfileLifecycle.valueOf(profileLifecycleString.toUpperCase()));
245+
options.setProfileLifecycle(
246+
ProfileLifecycle.valueOf(profileLifecycleString.toUpperCase(Locale.ROOT)));
246247
}
247248

248249
return options;

‎sentry/src/main/java/io/sentry/Hint.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public void set(@NotNull String name, @Nullable Object hint) {
6060
}
6161

6262
@SuppressWarnings("unchecked")
63-
public <T extends Object> @Nullable T getAs(@NotNull String name, @NotNull Class<T> clazz) {
63+
public <T> @Nullable T getAs(@NotNull String name, @NotNull Class<T> clazz) {
6464
try (final @NotNull ISentryLifecycleToken ignored = lock.acquire()) {
6565
Object hintValue = internalStorage.get(name);
6666

‎sentry/src/main/java/io/sentry/SamplingContext.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public final class SamplingContext {
2020

2121
@Deprecated
2222
@SuppressWarnings("InlineMeSuggester")
23-
/**
23+
/*
2424
* @deprecated creating a SamplingContext is something only the SDK should do
2525
*/
2626
public SamplingContext(

‎sentry/src/main/java/io/sentry/Scope.java‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -463,10 +463,10 @@ public Queue<Breadcrumb> getBreadcrumbs() {
463463
*/
464464
private @Nullable Breadcrumb executeBeforeBreadcrumb(
465465
final @NotNull SentryOptions.BeforeBreadcrumbCallback callback,
466-
@NotNull Breadcrumb breadcrumb,
466+
final @NotNull Breadcrumb breadcrumb,
467467
final @NotNull Hint hint) {
468468
try (final @NotNull ISentryLifecycleToken ignored = SentryCallbackReentrancyGuard.enter()) {
469-
breadcrumb = callback.execute(breadcrumb, hint);
469+
return callback.execute(breadcrumb, hint);
470470
} catch (Throwable e) {
471471
options
472472
.getLogger()
@@ -476,7 +476,6 @@ public Queue<Breadcrumb> getBreadcrumbs() {
476476
e);
477477
return null;
478478
}
479-
return breadcrumb;
480479
}
481480

482481
/**

‎sentry/src/main/java/io/sentry/SentryEnvelopeItem.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -691,11 +691,12 @@ private static class CachedItem {
691691
private @Nullable byte[] bytes;
692692
private final @Nullable Callable<byte[]> dataFactory;
693693

694-
public CachedItem(final @Nullable Callable<byte[]> dataFactory) {
694+
CachedItem(final @Nullable Callable<byte[]> dataFactory) {
695695
this.dataFactory = dataFactory;
696696
}
697697

698-
public @NotNull byte[] getBytes() throws Exception {
698+
@NotNull
699+
byte[] getBytes() throws Exception {
699700
if (bytes == null && dataFactory != null) {
700701
bytes = dataFactory.call();
701702
}

‎sentry/src/main/java/io/sentry/SentryExceptionFactory.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import java.util.Deque;
1212
import java.util.HashSet;
1313
import java.util.List;
14+
import java.util.Set;
1415
import java.util.concurrent.atomic.AtomicInteger;
1516
import org.jetbrains.annotations.ApiStatus;
1617
import org.jetbrains.annotations.NotNull;
@@ -141,7 +142,7 @@ Deque<SentryException> extractExceptionQueue(final @NotNull Throwable throwable)
141142
Deque<SentryException> extractExceptionQueueInternal(
142143
final @NotNull Throwable throwable,
143144
final @NotNull AtomicInteger exceptionId,
144-
final @NotNull HashSet<Throwable> circularityDetector,
145+
final @NotNull Set<Throwable> circularityDetector,
145146
final @NotNull Deque<SentryException> exceptions,
146147
@Nullable String mechanismTypeOverride) {
147148
Mechanism exceptionMechanism;

0 commit comments

Comments
 (0)