Skip to content

Commit 1564554

Browse files
authored
fix(logs): Reject new logs if LoggerBatchProcessor is shutting down (#5041)
1 parent 8df0d02 commit 1564554

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111

1212
- Only attach user attributes to logs if `sendDefaultPii` is enabled ([#5036](https://github.com/getsentry/sentry-java/pull/5036))
1313

14+
### Fixes
15+
16+
- Reject new logs if `LoggerBatchProcessor` is shutting down ([#5041](https://github.com/getsentry/sentry-java/pull/5041))
17+
1418
### Dependencies
1519

1620
- Bump Native SDK from v0.12.2 to v0.12.3 ([#5012](https://github.com/getsentry/sentry-java/pull/5012))

sentry/src/main/java/io/sentry/logger/LoggerBatchProcessor.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public class LoggerBatchProcessor implements ILoggerBatchProcessor {
3838
private volatile @Nullable Future<?> scheduledFlush;
3939
private final @NotNull AutoClosableReentrantLock scheduleLock = new AutoClosableReentrantLock();
4040
private volatile boolean hasScheduled = false;
41+
private volatile boolean isShuttingDown = false;
4142

4243
private final @NotNull ReusableCountLatch pendingCount = new ReusableCountLatch();
4344

@@ -51,6 +52,9 @@ public LoggerBatchProcessor(
5152

5253
@Override
5354
public void add(final @NotNull SentryLogEvent logEvent) {
55+
if (isShuttingDown) {
56+
return;
57+
}
5458
if (pendingCount.getCount() >= MAX_QUEUE_SIZE) {
5559
options
5660
.getClientReportRecorder()
@@ -70,6 +74,7 @@ public void add(final @NotNull SentryLogEvent logEvent) {
7074
@SuppressWarnings("FutureReturnValueIgnored")
7175
@Override
7276
public void close(final boolean isRestarting) {
77+
isShuttingDown = true;
7378
if (isRestarting) {
7479
maybeSchedule(true, true);
7580
executorService.submit(() -> executorService.close(options.getShutdownTimeoutMillis()));

0 commit comments

Comments
 (0)