From 434913bf3710364f186f9048d247c0e1b088d530 Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Tue, 18 Jan 2022 12:53:12 -0300 Subject: [PATCH 1/2] Ref: Add shutdownTimeoutMillis in favor of shutdownTimeout --- CHANGELOG.md | 1 + .../java/io/sentry/samples/console/Main.java | 2 +- .../samples/servlet/SentryInitializer.java | 2 +- .../boot/SentryAutoConfigurationTest.kt | 2 +- sentry/src/main/java/io/sentry/Hub.java | 2 +- .../src/main/java/io/sentry/SentryClient.java | 2 +- .../main/java/io/sentry/SentryOptions.java | 32 ++++++++++++++++--- 7 files changed, 34 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 70d37ea7f8..eb3a5ec222 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * Feat: Relax TransactionNameProvider (#1861) * Ref: Simplify DateUtils with ISO8601Utils (#1837) +* Ref: Add shutdownTimeoutMillis in favor of shutdownTimeout (#) ## 6.0.0-alpha.1 diff --git a/sentry-samples/sentry-samples-console/src/main/java/io/sentry/samples/console/Main.java b/sentry-samples/sentry-samples-console/src/main/java/io/sentry/samples/console/Main.java index d8be4e6825..409f58c81a 100644 --- a/sentry-samples/sentry-samples-console/src/main/java/io/sentry/samples/console/Main.java +++ b/sentry-samples/sentry-samples-console/src/main/java/io/sentry/samples/console/Main.java @@ -49,7 +49,7 @@ public static void main(String[] args) throws InterruptedException { // Configure the background worker which sends events to sentry: // Wait up to 5 seconds before shutdown while there are events to send. - options.setShutdownTimeout(5000); + options.setShutdownTimeoutMillis(5000); // Enable SDK logging with Debug level options.setDebug(true); diff --git a/sentry-samples/sentry-samples-servlet/src/main/java/io/sentry/samples/servlet/SentryInitializer.java b/sentry-samples/sentry-samples-servlet/src/main/java/io/sentry/samples/servlet/SentryInitializer.java index b7f31d37c2..03025144de 100644 --- a/sentry-samples/sentry-samples-servlet/src/main/java/io/sentry/samples/servlet/SentryInitializer.java +++ b/sentry-samples/sentry-samples-servlet/src/main/java/io/sentry/samples/servlet/SentryInitializer.java @@ -45,7 +45,7 @@ public void onStartup(Set> c, ServletContext ctx) throws ServletExcepti // Configure the background worker which sends events to sentry: // Wait up to 5 seconds before shutdown while there are events to send. - options.setShutdownTimeout(5000); + options.setShutdownTimeoutMillis(5000); // Enable SDK logging with Debug level options.setDebug(true); diff --git a/sentry-spring-boot-starter/src/test/kotlin/io/sentry/spring/boot/SentryAutoConfigurationTest.kt b/sentry-spring-boot-starter/src/test/kotlin/io/sentry/spring/boot/SentryAutoConfigurationTest.kt index f4852c6953..f33bff406f 100644 --- a/sentry-spring-boot-starter/src/test/kotlin/io/sentry/spring/boot/SentryAutoConfigurationTest.kt +++ b/sentry-spring-boot-starter/src/test/kotlin/io/sentry/spring/boot/SentryAutoConfigurationTest.kt @@ -154,7 +154,7 @@ class SentryAutoConfigurationTest { ).run { val options = it.getBean(SentryProperties::class.java) assertThat(options.readTimeoutMillis).isEqualTo(10) - assertThat(options.shutdownTimeout).isEqualTo(20) + assertThat(options.shutdownTimeoutMillis).isEqualTo(20) assertThat(options.flushTimeoutMillis).isEqualTo(30) assertThat(options.isDebug).isTrue() assertThat(options.diagnosticLevel).isEqualTo(SentryLevel.INFO) diff --git a/sentry/src/main/java/io/sentry/Hub.java b/sentry/src/main/java/io/sentry/Hub.java index 2decd790fb..56309475ce 100644 --- a/sentry/src/main/java/io/sentry/Hub.java +++ b/sentry/src/main/java/io/sentry/Hub.java @@ -271,7 +271,7 @@ public void close() { ((Closeable) integration).close(); } } - options.getExecutorService().close(options.getShutdownTimeout()); + options.getExecutorService().close(options.getShutdownTimeoutMillis()); // Close the top-most client final StackItem item = stack.peek(); diff --git a/sentry/src/main/java/io/sentry/SentryClient.java b/sentry/src/main/java/io/sentry/SentryClient.java index b7fb87f490..d69ea36323 100644 --- a/sentry/src/main/java/io/sentry/SentryClient.java +++ b/sentry/src/main/java/io/sentry/SentryClient.java @@ -577,7 +577,7 @@ public void close() { options.getLogger().log(SentryLevel.INFO, "Closing SentryClient."); try { - flush(options.getShutdownTimeout()); + flush(options.getShutdownTimeoutMillis()); transport.close(); } catch (IOException e) { options diff --git a/sentry/src/main/java/io/sentry/SentryOptions.java b/sentry/src/main/java/io/sentry/SentryOptions.java index 3e9f36e996..aa537f4878 100644 --- a/sentry/src/main/java/io/sentry/SentryOptions.java +++ b/sentry/src/main/java/io/sentry/SentryOptions.java @@ -57,7 +57,7 @@ public class SentryOptions { * background queue and this queue is given a certain amount to drain pending events Default is * 2000 = 2s */ - private long shutdownTimeout = 2000; // 2s + private long shutdownTimeoutMillis = 2000; // 2s /** * Controls how many seconds to wait before flushing down. Sentry SDKs cache events from a @@ -213,7 +213,7 @@ public class SentryOptions { /** Automatically resolve server name. */ private boolean attachServerName = true; - /* + /** When enabled, Sentry installs UncaughtExceptionHandlerIntegration. */ private boolean enableUncaughtExceptionHandler = true; @@ -464,19 +464,43 @@ public void setEnableNdk(boolean enableNdk) { /** * Returns the shutdown timeout in Millis * + * @deprecated use {{@link SentryOptions#getShutdownTimeoutMillis()} } * @return the timeout in Millis */ + @ApiStatus.ScheduledForRemoval + @Deprecated public long getShutdownTimeout() { - return shutdownTimeout; + return shutdownTimeoutMillis; + } + + /** + * Returns the shutdown timeout in Millis + * + * @return the timeout in Millis + */ + public long getShutdownTimeoutMillis() { + return shutdownTimeoutMillis; } /** * Sets the shutdown timeout in Millis Default is 2000 = 2s * + * @deprecated use {{@link SentryOptions#setShutdownTimeoutMillis(long)} } * @param shutdownTimeoutMillis the shutdown timeout in millis */ + @ApiStatus.ScheduledForRemoval + @Deprecated public void setShutdownTimeout(long shutdownTimeoutMillis) { - this.shutdownTimeout = shutdownTimeoutMillis; + this.shutdownTimeoutMillis = shutdownTimeoutMillis; + } + + /** + * Sets the shutdown timeout in Millis Default is 2000 = 2s + * + * @param shutdownTimeoutMillis the shutdown timeout in millis + */ + public void setShutdownTimeoutMillis(long shutdownTimeoutMillis) { + this.shutdownTimeoutMillis = shutdownTimeoutMillis; } /** From 3abdb5b1c285df6a6686ab08f35b671a1afbe7aa Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Tue, 18 Jan 2022 12:55:36 -0300 Subject: [PATCH 2/2] pr id and api --- CHANGELOG.md | 2 +- sentry/api/sentry.api | 2 ++ sentry/src/main/java/io/sentry/SentryOptions.java | 4 +--- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb3a5ec222..7f27feb897 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ * Feat: Relax TransactionNameProvider (#1861) * Ref: Simplify DateUtils with ISO8601Utils (#1837) -* Ref: Add shutdownTimeoutMillis in favor of shutdownTimeout (#) +* Ref: Add shutdownTimeoutMillis in favor of shutdownTimeout (#1873) ## 6.0.0-alpha.1 diff --git a/sentry/api/sentry.api b/sentry/api/sentry.api index 0f39e55695..38ea2c089f 100644 --- a/sentry/api/sentry.api +++ b/sentry/api/sentry.api @@ -1042,6 +1042,7 @@ public class io/sentry/SentryOptions { public fun getServerName ()Ljava/lang/String; public fun getSessionTrackingIntervalMillis ()J public fun getShutdownTimeout ()J + public fun getShutdownTimeoutMillis ()J public fun getSslSocketFactory ()Ljavax/net/ssl/SSLSocketFactory; public fun getTags ()Ljava/util/Map; public fun getTracesSampleRate ()Ljava/lang/Double; @@ -1110,6 +1111,7 @@ public class io/sentry/SentryOptions { public fun setServerName (Ljava/lang/String;)V public fun setSessionTrackingIntervalMillis (J)V public fun setShutdownTimeout (J)V + public fun setShutdownTimeoutMillis (J)V public fun setSslSocketFactory (Ljavax/net/ssl/SSLSocketFactory;)V public fun setTag (Ljava/lang/String;Ljava/lang/String;)V public fun setTraceSampling (Z)V diff --git a/sentry/src/main/java/io/sentry/SentryOptions.java b/sentry/src/main/java/io/sentry/SentryOptions.java index aa537f4878..c482e029ef 100644 --- a/sentry/src/main/java/io/sentry/SentryOptions.java +++ b/sentry/src/main/java/io/sentry/SentryOptions.java @@ -213,9 +213,7 @@ public class SentryOptions { /** Automatically resolve server name. */ private boolean attachServerName = true; - /** - When enabled, Sentry installs UncaughtExceptionHandlerIntegration. - */ + /** When enabled, Sentry installs UncaughtExceptionHandlerIntegration. */ private boolean enableUncaughtExceptionHandler = true; /** Sentry Executor Service that sends cached events and envelopes on App. start. */