Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Fixes

- Restore the interrupt flag when cached envelope processing is interrupted between files ([#5884](https://github.com/getsentry/sentry-java/issues/5884))
- Prevent inflated cold app start when the OS spawns the process in the background (e.g. FCM push) on API 35+ ([#5841](https://github.com/getsentry/sentry-java/pull/5841), [#5880](https://github.com/getsentry/sentry-java/pull/5880))
- Preserve single-sample ANR profile chunks so profiles remain available on ANR events ([#5872](https://github.com/getsentry/sentry-java/pull/5872))
- Avoid a CPU busy-loop when recording discarded log or metric envelopes under rate limiting ([#5835](https://github.com/getsentry/sentry-java/pull/5835))
Expand Down
3 changes: 3 additions & 0 deletions sentry/src/main/java/io/sentry/DirectoryProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ public void processDirectory(final @NotNull File directory) {
Thread.sleep(ENVELOPE_PROCESSING_DELAY);
}
} catch (Throwable e) {
if (e instanceof InterruptedException) {
Thread.currentThread().interrupt();
}
logger.log(SentryLevel.ERROR, e, "Failed processing '%s'", directory.getAbsolutePath());
}
}
Expand Down
23 changes: 23 additions & 0 deletions sentry/src/test/java/io/sentry/DirectoryProcessorTest.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.sentry

import com.google.common.truth.Truth.assertThat
import io.sentry.hints.ApplyScopeData
import io.sentry.hints.Enqueable
import io.sentry.hints.Retryable
Expand Down Expand Up @@ -135,6 +136,28 @@ class DirectoryProcessorTest {
verify(fixture.scopes).captureEvent(any(), anyOrNull<Hint>())
}

@Test
fun `when envelope processing delay is interrupted, restores interrupt flag`() {
getTempEnvelope("envelope-event-attachment.txt")
val sut =
object : DirectoryProcessor(fixture.scopes, fixture.logger, 500, 30) {
override fun processFile(file: File, hint: Hint) = Unit

override fun isRelevantFileName(fileName: String): Boolean = true
}

Thread.currentThread().interrupt()
val interruptFlagRestored =
try {
sut.processDirectory(file)
Thread.currentThread().isInterrupted
} finally {
Thread.interrupted()
}

assertThat(interruptFlagRestored).isTrue()
}

private fun getTempEnvelope(fileName: String): String {
val testFile = this::class.java.classLoader.getResource(fileName)
val testFileBytes = testFile!!.readBytes()
Expand Down
Loading