Skip to content

Commit b202421

Browse files
committed
changelog
1 parent 0f53aca commit b202421

3 files changed

Lines changed: 13 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
### Performance
1010

1111
- Reduce the number of SDK threads: `LifecycleWatcher` now schedules the session-end task on the shared timer executor instead of creating a dedicated `java.util.Timer` thread ([#5819](https://github.com/getsentry/sentry-java/pull/5819))
12+
- Reduce the number of SDK threads: `RateLimiter` now schedules its rate-limit-lifted notifications on the shared timer executor instead of creating a dedicated `java.util.Timer` thread ([#5814](https://github.com/getsentry/sentry-java/pull/5814))
1213

1314
## 8.50.0
1415

sentry/src/main/java/io/sentry/transport/RateLimiter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ private void applyRetryAfterOnlyIfLonger(
328328
notifyObserversFutures.add(
329329
options
330330
.getTimerExecutorService()
331-
.schedule(() -> notifyRateLimitObservers(), delayMillis));
331+
.schedule(this::notifyRateLimitObservers, delayMillis));
332332
} catch (RejectedExecutionException e) {
333333
options
334334
.getLogger()

sentry/src/test/java/io/sentry/transport/RateLimiterTest.kt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import java.io.File
4343
import java.util.UUID
4444
import java.util.concurrent.Future
4545
import java.util.concurrent.atomic.AtomicBoolean
46+
import kotlin.test.AfterTest
4647
import kotlin.test.Test
4748
import kotlin.test.assertEquals
4849
import kotlin.test.assertFalse
@@ -63,11 +64,14 @@ class RateLimiterTest {
6364
val currentDateProvider = mock<ICurrentDateProvider>()
6465
val clientReportRecorder = mock<IClientReportRecorder>()
6566
val serializer = mock<ISerializer>()
67+
var executorService: SentryExecutorService? = null
6668

6769
fun getSUT(): RateLimiter {
6870
val options = SentryOptions().apply { setLogger(NoOpLogger.getInstance()) }
6971
// a real executor so scheduled rate-limit-lifted notifications actually run
70-
options.setTimerExecutorService(SentryExecutorService(options))
72+
val timerExecutorService = SentryExecutorService(options)
73+
executorService = timerExecutorService
74+
options.setTimerExecutorService(timerExecutorService)
7175

7276
SentryOptionsManipulator.setClientReportRecorder(options, clientReportRecorder)
7377

@@ -77,6 +81,12 @@ class RateLimiterTest {
7781

7882
private val fixture = Fixture()
7983

84+
@AfterTest
85+
fun `tear down`() {
86+
// the executor's core thread never times out, so it would stay parked for the whole test JVM
87+
fixture.executorService?.close(0)
88+
}
89+
8090
@Test
8191
fun `uses X-Sentry-Rate-Limit and allows sending if time has passed`() {
8292
val rateLimiter = fixture.getSUT()

0 commit comments

Comments
 (0)