@@ -174,20 +174,23 @@ public void close(final boolean isRestarting) throws IOException {
174174 executor .shutdown ();
175175 options .getLogger ().log (SentryLevel .DEBUG , "Shutting down" );
176176 try {
177- // We need a small timeout to be able to save to disk any rejected envelope
178- long timeout = isRestarting ? 0 : options .getFlushTimeoutMillis ();
179- if (!executor .awaitTermination (timeout , TimeUnit .MILLISECONDS )) {
180- options
181- .getLogger ()
182- .log (
183- SentryLevel .WARNING ,
184- "Failed to shutdown the async connection async sender within "
185- + timeout
186- + " ms. Trying to force it now." );
187- executor .shutdownNow ();
188- if (currentRunnable != null ) {
189- // We store to disk any envelope that is currently being sent
190- executor .getRejectedExecutionHandler ().rejectedExecution (currentRunnable , executor );
177+ // only stop sending events on a real shutdown, not on a restart
178+ if (!isRestarting ) {
179+ // We need a small timeout to be able to save to disk any rejected envelope
180+ long timeout = options .getFlushTimeoutMillis ();
181+ if (!executor .awaitTermination (timeout , TimeUnit .MILLISECONDS )) {
182+ options
183+ .getLogger ()
184+ .log (
185+ SentryLevel .WARNING ,
186+ "Failed to shutdown the async connection async sender within "
187+ + timeout
188+ + " ms. Trying to force it now." );
189+ executor .shutdownNow ();
190+ if (currentRunnable != null ) {
191+ // We store to disk any envelope that is currently being sent
192+ executor .getRejectedExecutionHandler ().rejectedExecution (currentRunnable , executor );
193+ }
191194 }
192195 }
193196 } catch (InterruptedException e ) {
0 commit comments