Skip to content

Commit 9df2aa8

Browse files
runningcodeclaude
andcommitted
test: Remove the tests added for rethrowing fatal errors
Refs #5513 Refs JAVA-552 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent e0845ce commit 9df2aa8

11 files changed

Lines changed: 0 additions & 344 deletions

File tree

‎sentry-android-core/src/test/java/io/sentry/android/core/ANRWatchDogTest.kt‎

Lines changed: 0 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,20 @@ import android.app.ActivityManager
44
import android.app.ActivityManager.ProcessErrorStateInfo.NOT_RESPONDING
55
import android.app.ActivityManager.ProcessErrorStateInfo.NO_ERROR
66
import android.content.Context
7-
import com.google.common.truth.Truth.assertThat
87
import io.sentry.time.TestMonotonicTicker
98
import java.util.concurrent.CountDownLatch
10-
import java.util.concurrent.ExecutionException
119
import java.util.concurrent.Executors
1210
import java.util.concurrent.TimeUnit
1311
import java.util.concurrent.TimeUnit.MILLISECONDS
1412
import kotlin.test.Test
1513
import kotlin.test.assertEquals
16-
import kotlin.test.assertFailsWith
17-
import kotlin.test.assertFalse
1814
import kotlin.test.assertNotNull
1915
import kotlin.test.assertNull
2016
import kotlin.test.assertTrue
2117
import org.junit.Before
2218
import org.mockito.kotlin.any
23-
import org.mockito.kotlin.atLeastOnce
2419
import org.mockito.kotlin.eq
2520
import org.mockito.kotlin.mock
26-
import org.mockito.kotlin.mockingDetails
27-
import org.mockito.kotlin.verify
2821
import org.mockito.kotlin.whenever
2922

3023
class ANRWatchDogTest {
@@ -236,82 +229,6 @@ class ANRWatchDogTest {
236229
}
237230
}
238231

239-
@Test
240-
fun `when getProcessesInErrorState runs out of memory, keeps watching without reporting`() {
241-
var anr: ApplicationNotResponding? = null
242-
val am = mock<ActivityManager>()
243-
whenever(am.processesInErrorState).thenThrow(OutOfMemoryError("large reply"))
244-
val posted = CountDownLatch(1)
245-
val sut = watchDog(am, posted) { a -> anr = a }
246-
val es = Executors.newSingleThreadExecutor()
247-
try {
248-
val running = es.submit { sut.run() }
249-
assertTrue(posted.await(10L, TimeUnit.SECONDS))
250-
251-
var waitCount = 0
252-
do {
253-
ticker.advance(100, MILLISECONDS)
254-
Thread.sleep(100L)
255-
} while (mockingDetails(am).invocations.isEmpty() && waitCount++ < 100)
256-
257-
verify(am, atLeastOnce()).processesInErrorState
258-
assertNull(anr)
259-
assertFalse(running.isDone)
260-
} finally {
261-
sut.interrupt()
262-
es.shutdown()
263-
}
264-
}
265-
266-
@Test
267-
fun `when getProcessesInErrorState throws a fatal error, the watchdog stops`() {
268-
val am = mock<ActivityManager>()
269-
whenever(am.processesInErrorState).thenThrow(StackOverflowError())
270-
val posted = CountDownLatch(1)
271-
val sut = watchDog(am, posted) {}
272-
val es = Executors.newSingleThreadExecutor()
273-
try {
274-
val running = es.submit { sut.run() }
275-
assertTrue(posted.await(10L, TimeUnit.SECONDS))
276-
277-
var waitCount = 0
278-
do {
279-
ticker.advance(100, MILLISECONDS)
280-
Thread.sleep(100L)
281-
} while (!running.isDone && waitCount++ < 100)
282-
283-
val error = assertFailsWith<ExecutionException> { running.get() }
284-
assertThat(error.cause).isInstanceOf(StackOverflowError::class.java)
285-
} finally {
286-
sut.interrupt()
287-
es.shutdown()
288-
}
289-
}
290-
291-
private fun watchDog(
292-
am: ActivityManager,
293-
posted: CountDownLatch,
294-
listener: ANRWatchDog.ANRListener,
295-
): ANRWatchDog {
296-
val handler = mock<MainLooperHandler>()
297-
// the posted runnable never runs, so the main thread looks blocked
298-
whenever(handler.post(any())).then { posted.countDown() }
299-
whenever(handler.thread).thenReturn(mock<Thread>())
300-
val context = mock<Context>()
301-
whenever(context.getSystemService(eq(Context.ACTIVITY_SERVICE))).thenReturn(am)
302-
return ANRWatchDog(
303-
ticker,
304-
10L,
305-
1L,
306-
true,
307-
listener,
308-
mock(),
309-
handler,
310-
context,
311-
AndroidDebugManager(),
312-
)
313-
}
314-
315232
@Test
316233
fun `measures the ANR threshold on the ticker, not on wall time`() {
317234
var anr: ApplicationNotResponding? = null

‎sentry-android-core/src/test/java/io/sentry/android/core/AnrV2IntegrationTest.kt‎

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -237,26 +237,6 @@ class AnrV2IntegrationTest : ApplicationExitIntegrationTestBase<AnrV2Hint>() {
237237
verify(fixture.scopes, never()).captureEvent(any(), anyOrNull<Hint>())
238238
}
239239

240-
@Test
241-
fun `when reading the trace throws a runtime exception, does not report ANR`() {
242-
val integration = fixture.getSut(tmpDir, lastReportedTimestamp = oldTimestamp)
243-
val exitInfo =
244-
spy(
245-
ApplicationExitInfoBuilder.newBuilder()
246-
.setReason(ApplicationExitInfo.REASON_ANR)
247-
.setTimestamp(newTimestamp)
248-
.build(),
249-
) {
250-
// getTraceInputStream() is a Binder call, which rethrows exceptions from system_server
251-
whenever(mock.traceInputStream).thenThrow(SecurityException("denied"))
252-
}
253-
fixture.shadowActivityManager.addApplicationExitInfo(exitInfo)
254-
255-
integration.register(fixture.scopes, fixture.options)
256-
257-
verify(fixture.scopes, never()).captureEvent(any(), anyOrNull<Hint>())
258-
}
259-
260240
@Test
261241
fun `when traceInputStream has bad data, does not report ANR`() {
262242
val integration = fixture.getSut(tmpDir, lastReportedTimestamp = oldTimestamp)

‎sentry-android-core/src/test/java/io/sentry/android/core/SentryAndroidTest.kt‎

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -217,19 +217,6 @@ class SentryAndroidTest {
217217
assertTrue(Sentry.isEnabled())
218218
}
219219

220-
@Test
221-
fun `when the configuration handler throws, init continues with the options it set`() {
222-
var refOptions: SentryAndroidOptions? = null
223-
fixture.initSut {
224-
it.anrTimeoutIntervalMillis = 3000
225-
refOptions = it
226-
throw IllegalStateException("configuration failed")
227-
}
228-
229-
assertEquals(3000, refOptions!!.anrTimeoutIntervalMillis)
230-
assertTrue(Sentry.isEnabled())
231-
}
232-
233220
@Test
234221
fun `init won't throw exception`() {
235222
val logger = mock<ILogger>()

‎sentry-apollo-3/src/test/java/io/sentry/apollo3/SentryApollo3InterceptorTest.kt‎

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -484,27 +484,6 @@ class SentryApollo3InterceptorTest {
484484
)
485485
}
486486

487-
@Test
488-
fun `when beforeSpan throws a fatal error, rethrows it`(): Unit = runBlocking {
489-
val tx =
490-
SentryTracer(TransactionContext("op", "desc", TracesSamplingDecision(true)), fixture.scopes)
491-
whenever(fixture.scopes.span).thenReturn(tx)
492-
val chain =
493-
object : HttpInterceptorChain {
494-
override suspend fun proceed(request: HttpRequest): HttpResponse =
495-
HttpResponse.Builder(200).build()
496-
}
497-
val request = HttpRequest.Builder(HttpMethod.Post, "https://example.com/graphql").build()
498-
val interceptor =
499-
SentryApollo3HttpInterceptor(
500-
fixture.scopes,
501-
{ _, _, _ -> throw OutOfMemoryError("callback") },
502-
captureFailedRequests = false,
503-
)
504-
505-
assertFailsWith<OutOfMemoryError> { interceptor.intercept(request, chain) }
506-
}
507-
508487
@Test
509488
fun `adds breadcrumb when http calls succeeds`() {
510489
executeQuery(fixture.getSut())

‎sentry-apollo-4/src/test/java/io/sentry/apollo4/SentryApollo4HttpInterceptorTest.kt‎

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -498,27 +498,6 @@ abstract class SentryApollo4HttpInterceptorTest(
498498
)
499499
}
500500

501-
@Test
502-
fun `when beforeSpan throws a fatal error, rethrows it`(): Unit = runBlocking {
503-
val tx =
504-
SentryTracer(TransactionContext("op", "desc", TracesSamplingDecision(true)), fixture.scopes)
505-
whenever(fixture.scopes.span).thenReturn(tx)
506-
val chain =
507-
object : HttpInterceptorChain {
508-
override suspend fun proceed(request: HttpRequest): HttpResponse =
509-
HttpResponse.Builder(200).build()
510-
}
511-
val request = HttpRequest.Builder(HttpMethod.Post, "https://example.com/graphql").build()
512-
val interceptor =
513-
SentryApollo4HttpInterceptor(
514-
fixture.scopes,
515-
{ _, _, _ -> throw OutOfMemoryError("callback") },
516-
captureFailedRequests = false,
517-
)
518-
519-
assertFailsWith<OutOfMemoryError> { interceptor.intercept(request, chain) }
520-
}
521-
522501
@Test
523502
fun `adds breadcrumb when http calls succeeds`() {
524503
executeQuery(fixture.getSut())

‎sentry-logback/src/test/kotlin/io/sentry/logback/SentryAppenderTest.kt‎

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import kotlin.test.AfterTest
3232
import kotlin.test.BeforeTest
3333
import kotlin.test.Test
3434
import kotlin.test.assertEquals
35-
import kotlin.test.assertFailsWith
3635
import kotlin.test.assertFalse
3736
import kotlin.test.assertNotNull
3837
import kotlin.test.assertNull
@@ -330,22 +329,6 @@ class SentryAppenderTest {
330329
)
331330
}
332331

333-
class FatalEncoder : EncoderBase<ILoggingEvent>() {
334-
override fun headerBytes(): ByteArray = ByteArray(0)
335-
336-
override fun footerBytes(): ByteArray = ByteArray(0)
337-
338-
override fun encode(event: ILoggingEvent?): ByteArray = throw OutOfMemoryError("encoder")
339-
}
340-
341-
@Test
342-
fun `rethrows a fatal error from the encoder`() {
343-
fixture =
344-
Fixture(minimumEventLevel = Level.DEBUG, encoder = FatalEncoder(), sendDefaultPii = true)
345-
346-
assertFailsWith<OutOfMemoryError> { fixture.logger.info("testing a fatal encoder error") }
347-
}
348-
349332
@Test
350333
fun `event date is in UTC`() {
351334
fixture = Fixture(minimumEventLevel = Level.DEBUG)

‎sentry/src/test/java/io/sentry/ScopeTest.kt‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import io.sentry.test.callMethod
1010
import java.util.concurrent.CopyOnWriteArrayList
1111
import kotlin.test.Test
1212
import kotlin.test.assertEquals
13-
import kotlin.test.assertFailsWith
1413
import kotlin.test.assertFalse
1514
import kotlin.test.assertNotNull
1615
import kotlin.test.assertNotSame
@@ -379,17 +378,6 @@ class ScopeTest {
379378
assertThat(scope.breadcrumbs.single().message).isEqualTo("kept")
380379
}
381380

382-
@Test
383-
fun `when beforeBreadcrumb throws a fatal error, it propagates`() {
384-
val options =
385-
SentryOptions().apply { setBeforeBreadcrumb { _, _ -> throw OutOfMemoryError("test") } }
386-
387-
val scope = Scope(options)
388-
389-
assertFailsWith<OutOfMemoryError> { scope.addBreadcrumb(Breadcrumb()) }
390-
assertThat(scope.breadcrumbs).isEmpty()
391-
}
392-
393381
@Test
394382
fun `when adding breadcrumb, executeBreadcrumb wont be executed as its not set, but it will be added`() {
395383
val options = SentryOptions()

0 commit comments

Comments
 (0)