Skip to content

Commit 19bdc37

Browse files
committed
Merge branch 'main' into feat/otlp
2 parents 6dd288b + 9dc12d1 commit 19bdc37

File tree

4 files changed

+29
-3
lines changed

4 files changed

+29
-3
lines changed

sentry-test-support/api/sentry-test-support.api

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,16 @@ public final class io/sentry/test/MocksKt {
5555
public static synthetic fun createTestScopes$default (Lio/sentry/SentryOptions;ZLio/sentry/IScope;Lio/sentry/IScope;Lio/sentry/IScope;ILjava/lang/Object;)Lio/sentry/Scopes;
5656
}
5757

58+
public final class io/sentry/test/NonOverridableNoOpSentryExecutorService : io/sentry/ISentryExecutorService {
59+
public fun <init> ()V
60+
public fun close (J)V
61+
public fun isClosed ()Z
62+
public fun prewarm ()V
63+
public fun schedule (Ljava/lang/Runnable;J)Ljava/util/concurrent/Future;
64+
public fun submit (Ljava/lang/Runnable;)Ljava/util/concurrent/Future;
65+
public fun submit (Ljava/util/concurrent/Callable;)Ljava/util/concurrent/Future;
66+
}
67+
5868
public final class io/sentry/test/ReflectionKt {
5969
public static final fun collectInterfaceHierarchy (Ljava/lang/Class;)Ljava/util/List;
6070
public static final fun containsMethod (Ljava/lang/Class;Ljava/lang/String;Ljava/lang/Class;)Z

sentry-test-support/src/main/kotlin/io/sentry/test/Mocks.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,21 @@ class DeferredExecutorService : ISentryExecutorService {
7979
fun hasScheduledRunnables(): Boolean = scheduledRunnables.isNotEmpty()
8080
}
8181

82+
class NonOverridableNoOpSentryExecutorService : ISentryExecutorService {
83+
override fun submit(runnable: Runnable): Future<*> = FutureTask<Void> { null }
84+
85+
override fun <T> submit(callable: Callable<T>): Future<T> = FutureTask<T> { null }
86+
87+
override fun schedule(runnable: Runnable, delayMillis: Long): Future<*> =
88+
FutureTask<Void> { null }
89+
90+
override fun close(timeoutMillis: Long) {}
91+
92+
override fun isClosed(): Boolean = false
93+
94+
override fun prewarm() = Unit
95+
}
96+
8297
fun createSentryClientMock(enabled: Boolean = true) =
8398
mock<ISentryClient>().also {
8499
val isEnabled = AtomicBoolean(enabled)

sentry/src/test/java/io/sentry/MainEventProcessorTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ class MainEventProcessorTest {
258258

259259
assertNotNull(event.threads)
260260
assertEquals(1, event.threads!!.count { it.isCrashed == true })
261-
assertNotNull(event.threads!!.first().stacktrace)
261+
assertNotNull(event.threads!!.first { it.isCrashed == true }.stacktrace)
262262
}
263263

264264
@Test

sentry/src/test/java/io/sentry/SentryTest.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import io.sentry.protocol.SdkVersion
1717
import io.sentry.protocol.SentryId
1818
import io.sentry.protocol.SentryThread
1919
import io.sentry.test.ImmediateExecutorService
20+
import io.sentry.test.NonOverridableNoOpSentryExecutorService
2021
import io.sentry.test.createSentryClientMock
2122
import io.sentry.test.initForTest
2223
import io.sentry.test.injectForField
@@ -1217,7 +1218,7 @@ class SentryTest {
12171218
it.profilesSampleRate = 1.0
12181219
it.tracesSampler = mockSampleTracer
12191220
it.profilesSampler = mockProfilesSampler
1220-
it.executorService = NoOpSentryExecutorService.getInstance()
1221+
it.executorService = NonOverridableNoOpSentryExecutorService()
12211222
it.cacheDirPath = getTempPath()
12221223
}
12231224
// Samplers are called with isForNextAppStart flag set to true
@@ -1236,7 +1237,7 @@ class SentryTest {
12361237
it.profilesSampleRate = 1.0
12371238
it.tracesSampler = mockSampleTracer
12381239
it.profilesSampler = mockProfilesSampler
1239-
it.executorService = NoOpSentryExecutorService.getInstance()
1240+
it.executorService = NonOverridableNoOpSentryExecutorService()
12401241
it.cacheDirPath = null
12411242
}
12421243
// Samplers are called with isForNextAppStart flag set to true

0 commit comments

Comments
 (0)