Skip to content

Commit 3bb855b

Browse files
committed
fix(integrations): Resolve the Error Prone and javac 21 findings in the JVM integrations
1 parent 982954a commit 3bb855b

8 files changed

Lines changed: 16 additions & 8 deletions

File tree

‎sentry-async-profiler/src/main/java/io/sentry/asyncprofiler/convert/JfrAsyncProfilerToSentryProfileConverter.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ private class ProfileEventVisitor implements EventCollector.Visitor {
8383
private final @NotNull JfrReader jfr;
8484
private final @NotNull Arguments args;
8585

86-
public ProfileEventVisitor(
86+
ProfileEventVisitor(
8787
@NotNull SentryProfile sentryProfile,
8888
@NotNull SentryStackTraceFactory stackTraceFactory,
8989
@NotNull JfrReader jfr,

‎sentry-jul/src/main/java/io/sentry/jul/SentryHandler.java‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@
4040
import org.slf4j.MDC;
4141

4242
/** Logging handler in charge of sending the java.util.logging records to a Sentry server. */
43+
// temp fix for JDK 21: Constructors call overridable methods; making them final would break the
44+
// public API.
45+
@SuppressWarnings("this-escape")
4346
@Open
4447
public class SentryHandler extends Handler {
4548
public static final String MECHANISM_TYPE = "JulSentryHandler";

‎sentry-kafka/src/main/java/io/sentry/kafka/SentryKafkaConsumerTracing.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ private void finishTransaction(
247247

248248
try {
249249
final double enqueuedTimeSeconds = Double.parseDouble(enqueuedTimeStr);
250-
final double nowSeconds = DateUtils.millisToSeconds(System.currentTimeMillis());
250+
final double nowSeconds = DateUtils.millisToSeconds((double) System.currentTimeMillis());
251251
final long latencyMs = (long) ((nowSeconds - enqueuedTimeSeconds) * 1000);
252252
return latencyMs >= 0 ? latencyMs : null;
253253
} catch (NumberFormatException ignored) {

‎sentry-kafka/src/main/java/io/sentry/kafka/SentryKafkaProducer.java‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ static final class SentryProducerHandler<K, V> implements InvocationHandler {
114114
}
115115

116116
@Override
117-
@SuppressWarnings("unchecked")
117+
// temp fix for JDK 21: Proxy equals() is identity-based.
118+
@SuppressWarnings({"unchecked", "ReferenceEquality"})
118119
public @Nullable Object invoke(
119120
final @NotNull Object proxy, final @NotNull Method method, final @Nullable Object[] args)
120121
throws Throwable {
@@ -236,7 +237,8 @@ private void maybeInjectHeaders(final @NotNull Headers headers, final @Nullable
236237
headers.remove(SENTRY_ENQUEUED_TIME_HEADER);
237238
headers.add(
238239
SENTRY_ENQUEUED_TIME_HEADER,
239-
DateUtils.doubleToBigDecimal(DateUtils.millisToSeconds(System.currentTimeMillis()))
240+
DateUtils.doubleToBigDecimal(
241+
DateUtils.millisToSeconds((double) System.currentTimeMillis()))
240242
.toString()
241243
.getBytes(StandardCharsets.UTF_8));
242244
} catch (Throwable t) {

‎sentry-logback/src/main/java/io/sentry/logback/SentryAppender.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@ protected void captureLog(@NotNull ILoggingEvent loggingEvent) {
197197
final @NotNull SentryLogParameters params = SentryLogParameters.create(attributes);
198198
params.setOrigin("auto.log.logback");
199199

200-
Sentry.logger().log(sentryLevel, params, formattedMessage, arguments);
200+
Sentry.logger()
201+
.log(sentryLevel, params, formattedMessage, arguments != null ? arguments : new Object[0]);
201202
}
202203

203204
@SuppressWarnings("deprecation")

‎sentry-opentelemetry/sentry-opentelemetry-bootstrap/src/main/java/io/sentry/opentelemetry/OtelContextScopesStorage.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public final class OtelContextScopesStorage implements IScopesStorage {
1717

1818
@Override
1919
public void init() {
20-
/**
20+
/*
2121
* We're currently overriding the storage mechanism to allow for cleanup of non closed OTel
2222
* scopes. These happen when using e.g. Sentry static API due to getCurrentScopes() invoking
2323
* Context.makeCurrent and then ignoring the returned lifecycle token (OTel Scope). After fixing

‎sentry-opentelemetry/sentry-opentelemetry-bootstrap/src/main/java/io/sentry/opentelemetry/SentryOtelThreadLocalStorage.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ public final class SentryOtelThreadLocalStorage implements ContextStorage {
2929

3030
private static final ThreadLocal<Context> THREAD_LOCAL_STORAGE = new ThreadLocal<>();
3131

32+
// temp fix for JDK 21: Same identity check as OpenTelemetry's ThreadLocalContextStorage.
33+
@SuppressWarnings("ReferenceEquality")
3234
@Override
3335
public Scope attach(Context toAttach) {
3436
if (toAttach == null) {

‎sentry-reactor/src/main/java/io/sentry/reactor/SentryReactorUtils.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public static <T> Mono<T> withSentryForkedRoots(final @NotNull Mono<T> mono) {
4848
*/
4949
public static <T> Mono<T> withSentryScopes(
5050
final @NotNull Mono<T> mono, final @NotNull IScopes scopes) {
51-
/**
51+
/*
5252
* WARNING: Cannot set the scopes as current. It would be used by others to clone again causing
5353
* shared scopes and thus leading to issues like unrelated breadcrumbs showing up in events.
5454
*/
@@ -96,7 +96,7 @@ public static <T> Flux<T> withSentryForkedRoots(final @NotNull Flux<T> flux) {
9696
*/
9797
public static <T> Flux<T> withSentryScopes(
9898
final @NotNull Flux<T> flux, final @NotNull IScopes scopes) {
99-
/**
99+
/*
100100
* WARNING: Cannot set the scopes as current. It would be used by others to fork again causing
101101
* shared scopes and thus leading to issues like unrelated breadcrumbs showing up in events.
102102
*/

0 commit comments

Comments
 (0)