From 16d63afd84e1dd1ba30566fa22b057ceda614d70 Mon Sep 17 00:00:00 2001 From: Nelson Osacky Date: Wed, 21 Oct 2026 09:11:39 +0200 Subject: [PATCH 1/2] fix(profiling): Accept dots in the JVM profiling traces dir path JavaContinuousProfiler refused any traces directory whose path held one of 26 characters, including ".", so a cache dir like /home/app/.sentry or /opt/my.app logged "Disabling profiling". async-profiler only treats "," (its argument separator) and "%" (file name patterns) specially, so those are the only characters it still rejects. The check also only stopped the first start: init() marked itself done before validating and returned true from then on, so later starts went ahead with the rejected options. It now remembers the result, as the Android profiler does. Co-Authored-By: Claude Opus 5.5 (1M context) --- .../profiling/JavaContinuousProfiler.java | 10 ++++---- .../profiling/JavaContinuousProfilerTest.kt | 25 +++++++++++++++++++ 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/sentry-async-profiler/src/main/java/io/sentry/asyncprofiler/profiling/JavaContinuousProfiler.java b/sentry-async-profiler/src/main/java/io/sentry/asyncprofiler/profiling/JavaContinuousProfiler.java index 09c2ed8b5d2..ced363d4a58 100644 --- a/sentry-async-profiler/src/main/java/io/sentry/asyncprofiler/profiling/JavaContinuousProfiler.java +++ b/sentry-async-profiler/src/main/java/io/sentry/asyncprofiler/profiling/JavaContinuousProfiler.java @@ -42,16 +42,15 @@ public final class JavaContinuousProfiler implements IContinuousProfiler, RateLimiter.IRateLimitObserver { private static final long MAX_CHUNK_DURATION_MILLIS = 10000; - private final List invalidFilenameChars = - Arrays.asList( - ".", ",", ":", ";", "|", "\\", "=", "%", "&", "[", "]", "(", ")", "<", ">", "{", "}", "!", - "*", "?", "~", "\"", "'", "$", "`", "^"); + // async-profiler splits its arguments on "," and expands "%" patterns in the file name. + private final List invalidFilenameChars = Arrays.asList(",", "%"); private final @NotNull ILogger logger; private final @Nullable String profilingTracesDirPath; private final int profilingTracesHz; private final @NotNull ISentryExecutorService executorService; private boolean isInitialized = false; + private boolean hasValidOptions = false; private boolean isRunning = false; private @Nullable IScopes scopes; private @Nullable Future stopFuture; @@ -92,7 +91,7 @@ private void initializeProfiler() throws Exception { private boolean init() { if (isInitialized) { - return true; + return hasValidOptions; } isInitialized = true; @@ -107,6 +106,7 @@ private boolean init() { profilingTracesHz); return false; } + hasValidOptions = true; return true; } diff --git a/sentry-async-profiler/src/test/java/io/sentry/asyncprofiler/profiling/JavaContinuousProfilerTest.kt b/sentry-async-profiler/src/test/java/io/sentry/asyncprofiler/profiling/JavaContinuousProfilerTest.kt index 7764249e3eb..745139a20a6 100644 --- a/sentry-async-profiler/src/test/java/io/sentry/asyncprofiler/profiling/JavaContinuousProfilerTest.kt +++ b/sentry-async-profiler/src/test/java/io/sentry/asyncprofiler/profiling/JavaContinuousProfilerTest.kt @@ -421,6 +421,31 @@ class JavaContinuousProfilerTest { ) } + @Test + fun `profiler starts when the traces dir path contains a dot`() { + val profiler = fixture.getSut { + it.profilingTracesDirPath = File("tmp", "sentry.traces").absolutePath + } + File(fixture.options.profilingTracesDirPath!!).mkdirs() + + profiler.startProfiler(ProfileLifecycle.MANUAL, fixture.mockTracesSampler) + assertTrue(profiler.isRunning) + profiler.close(true) + } + + @Test + fun `profiler stays disabled when the traces dir is created after its first start`() { + val tracesDir = File(fixture.options.profilingTracesDirPath!!) + tracesDir.deleteRecursively() + val profiler = fixture.getSut() + profiler.startProfiler(ProfileLifecycle.MANUAL, fixture.mockTracesSampler) + assertFalse(profiler.isRunning) + + tracesDir.mkdirs() + profiler.startProfiler(ProfileLifecycle.MANUAL, fixture.mockTracesSampler) + assertFalse(profiler.isRunning) + } + fun withMockScopes(closure: () -> Unit) = Mockito.mockStatic(Sentry::class.java).use { it.`when` { Sentry.getCurrentScopes() }.thenReturn(fixture.scopes) From bc5ff498c870790b70d6cd8e8cc1e58d7b0634b8 Mon Sep 17 00:00:00 2001 From: Nelson Osacky Date: Wed, 21 Oct 2026 09:12:21 +0200 Subject: [PATCH 2/2] changelog Co-Authored-By: Claude Opus 5.5 (1M context) --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 15817dd70d3..01e188a855a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - Android 7.1.0 (API 25) and older don't trust the Let's Encrypt root certificate (ISRG Root X1), so without this fix, the SDK on those devices can no longer send events to Sentry after the switch. - The SDK now bundles ISRG Root X1 and trusts it in addition to the device's root certificates on API 25 and lower. This only applies to the SDK's own uploads to Sentry SaaS (DSNs on `sentry.io`), not to self-hosted Sentry, not to any other connection your app makes, and not if you set your own `SentryOptions.setSslSocketFactory`. - Apps need to update to an SDK version with this fix to keep sending events from these devices. +- Accept profiling traces directories whose path contains a `.` on the JVM, and keep profiling disabled after its first start rejects the options instead of starting on the next one ([#6334](https://github.com/getsentry/sentry-java/pull/6334)) ### Internal