Skip to content

Commit f92f47c

Browse files
adinauerclaude
andcommitted
fix(spring-jakarta): Initialize Sentry in consumer test, fix API file ordering
Add initForTest/close to SentryKafkaRecordInterceptorTest to fix NPE from TransactionContext constructor requiring initialized Sentry. Regenerate API file to fix alphabetical ordering of SentryProducerInterceptor entry. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 6450f63 commit f92f47c

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

sentry-spring-jakarta/api/sentry-spring-jakarta.api

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -256,14 +256,6 @@ public final class io/sentry/spring/jakarta/kafka/SentryKafkaProducerBeanPostPro
256256
public fun postProcessAfterInitialization (Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/Object;
257257
}
258258

259-
public final class io/sentry/spring/jakarta/kafka/SentryProducerInterceptor : org/apache/kafka/clients/producer/ProducerInterceptor {
260-
public fun <init> (Lio/sentry/IScopes;)V
261-
public fun close ()V
262-
public fun configure (Ljava/util/Map;)V
263-
public fun onAcknowledgement (Lorg/apache/kafka/clients/producer/RecordMetadata;Ljava/lang/Exception;)V
264-
public fun onSend (Lorg/apache/kafka/clients/producer/ProducerRecord;)Lorg/apache/kafka/clients/producer/ProducerRecord;
265-
}
266-
267259
public final class io/sentry/spring/jakarta/kafka/SentryKafkaRecordInterceptor : org/springframework/kafka/listener/RecordInterceptor {
268260
public fun <init> (Lio/sentry/IScopes;)V
269261
public fun <init> (Lio/sentry/IScopes;Lorg/springframework/kafka/listener/RecordInterceptor;)V
@@ -273,6 +265,14 @@ public final class io/sentry/spring/jakarta/kafka/SentryKafkaRecordInterceptor :
273265
public fun success (Lorg/apache/kafka/clients/consumer/ConsumerRecord;Lorg/apache/kafka/clients/consumer/Consumer;)V
274266
}
275267

268+
public final class io/sentry/spring/jakarta/kafka/SentryProducerInterceptor : org/apache/kafka/clients/producer/ProducerInterceptor {
269+
public fun <init> (Lio/sentry/IScopes;)V
270+
public fun close ()V
271+
public fun configure (Ljava/util/Map;)V
272+
public fun onAcknowledgement (Lorg/apache/kafka/clients/producer/RecordMetadata;Ljava/lang/Exception;)V
273+
public fun onSend (Lorg/apache/kafka/clients/producer/ProducerRecord;)Lorg/apache/kafka/clients/producer/ProducerRecord;
274+
}
275+
276276
public class io/sentry/spring/jakarta/opentelemetry/SentryOpenTelemetryAgentWithoutAutoInitConfiguration {
277277
public fun <init> ()V
278278
public fun sentryOpenTelemetryOptionsConfiguration ()Lio/sentry/Sentry$OptionsConfiguration;

sentry-spring-jakarta/src/test/kotlin/io/sentry/spring/jakarta/kafka/SentryKafkaRecordInterceptorTest.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@ package io.sentry.spring.jakarta.kafka
33
import io.sentry.BaggageHeader
44
import io.sentry.IScopes
55
import io.sentry.ISentryLifecycleToken
6+
import io.sentry.Sentry
67
import io.sentry.SentryOptions
78
import io.sentry.SentryTraceHeader
89
import io.sentry.SentryTracer
910
import io.sentry.TransactionContext
11+
import io.sentry.test.initForTest
1012
import java.nio.charset.StandardCharsets
13+
import kotlin.test.AfterTest
1114
import kotlin.test.BeforeTest
1215
import kotlin.test.Test
1316
import kotlin.test.assertEquals
@@ -30,6 +33,7 @@ class SentryKafkaRecordInterceptorTest {
3033

3134
@BeforeTest
3235
fun setup() {
36+
initForTest { it.dsn = "https://key@sentry.io/proj" }
3337
scopes = mock()
3438
consumer = mock()
3539
lifecycleToken = mock()
@@ -51,6 +55,11 @@ class SentryKafkaRecordInterceptorTest {
5155
whenever(forkedScopes.startTransaction(any<TransactionContext>(), any())).thenReturn(tx)
5256
}
5357

58+
@AfterTest
59+
fun teardown() {
60+
Sentry.close()
61+
}
62+
5463
private fun createRecord(
5564
topic: String = "my-topic",
5665
headers: RecordHeaders = RecordHeaders(),

0 commit comments

Comments
 (0)