From e6155e3da38c20e9d3f1d1b7d3c84a7c82430f83 Mon Sep 17 00:00:00 2001 From: Alexander Dinauer Date: Tue, 20 Jan 2026 10:12:16 +0100 Subject: [PATCH 1/2] Reject new logs if LoggerBatchProcessor is shutting down --- .../src/main/java/io/sentry/logger/LoggerBatchProcessor.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sentry/src/main/java/io/sentry/logger/LoggerBatchProcessor.java b/sentry/src/main/java/io/sentry/logger/LoggerBatchProcessor.java index 290087a641..1f9b8fe7ce 100644 --- a/sentry/src/main/java/io/sentry/logger/LoggerBatchProcessor.java +++ b/sentry/src/main/java/io/sentry/logger/LoggerBatchProcessor.java @@ -38,6 +38,7 @@ public class LoggerBatchProcessor implements ILoggerBatchProcessor { private volatile @Nullable Future scheduledFlush; private final @NotNull AutoClosableReentrantLock scheduleLock = new AutoClosableReentrantLock(); private volatile boolean hasScheduled = false; + private volatile boolean isShuttingDown = false; private final @NotNull ReusableCountLatch pendingCount = new ReusableCountLatch(); @@ -51,6 +52,9 @@ public LoggerBatchProcessor( @Override public void add(final @NotNull SentryLogEvent logEvent) { + if (isShuttingDown) { + return; + } if (pendingCount.getCount() >= MAX_QUEUE_SIZE) { options .getClientReportRecorder() @@ -70,6 +74,7 @@ public void add(final @NotNull SentryLogEvent logEvent) { @SuppressWarnings("FutureReturnValueIgnored") @Override public void close(final boolean isRestarting) { + isShuttingDown = true; if (isRestarting) { maybeSchedule(true, true); executorService.submit(() -> executorService.close(options.getShutdownTimeoutMillis())); From 757e4e848547e03104a90875eb16efd85c023e8e Mon Sep 17 00:00:00 2001 From: Alexander Dinauer Date: Tue, 20 Jan 2026 14:06:34 +0100 Subject: [PATCH 2/2] changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1aca5108ab..cec1e8c414 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ - Added `io.sentry.ndk.sdk-name` Android manifest option to configure the native SDK's name ([#5027](https://github.com/getsentry/sentry-java/pull/5027)) +### Fixes + +- Reject new logs if `LoggerBatchProcessor` is shutting down ([#5041](https://github.com/getsentry/sentry-java/pull/5041)) + ### Dependencies - Bump Native SDK from v0.12.2 to v0.12.3 ([#5012](https://github.com/getsentry/sentry-java/pull/5012))