File tree Expand file tree Collapse file tree
sentry/src/main/java/io/sentry/logger Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ public final class LoggerBatchProcessor implements ILoggerBatchProcessor {
2828 private volatile @ Nullable Future <?> scheduledFlush ;
2929 private static final @ NotNull AutoClosableReentrantLock scheduleLock =
3030 new AutoClosableReentrantLock ();
31+ private volatile boolean hasScheduled = false ;
3132
3233 public LoggerBatchProcessor (
3334 final @ NotNull SentryOptions options , final @ NotNull ISentryClient client ) {
@@ -58,12 +59,16 @@ public void close(final boolean isRestarting) {
5859 }
5960
6061 private void maybeSchedule (boolean forceSchedule , boolean immediately ) {
62+ if (hasScheduled && !forceSchedule ) {
63+ return ;
64+ }
6165 try (final @ NotNull ISentryLifecycleToken ignored = scheduleLock .acquire ()) {
6266 final @ Nullable Future <?> latestScheduledFlush = scheduledFlush ;
6367 if (forceSchedule
6468 || latestScheduledFlush == null
6569 || latestScheduledFlush .isDone ()
6670 || latestScheduledFlush .isCancelled ()) {
71+ hasScheduled = true ;
6772 final int flushAfterMs = immediately ? 0 : FLUSH_AFTER_MS ;
6873 scheduledFlush = executorService .schedule (new BatchRunnable (), flushAfterMs );
6974 }
@@ -75,6 +80,8 @@ private void flush() {
7580 try (final @ NotNull ISentryLifecycleToken ignored = scheduleLock .acquire ()) {
7681 if (!queue .isEmpty ()) {
7782 maybeSchedule (true , false );
83+ } else {
84+ hasScheduled = false ;
7885 }
7986 }
8087 }
You can’t perform that action at this time.
0 commit comments