From e66546a360945c328384b812c891cc95e146d834 Mon Sep 17 00:00:00 2001 From: zhengziyi Date: Wed, 30 Oct 2024 10:45:32 +0800 Subject: [PATCH] fix: some issue --- .../apm/agent/core/asyncprofiler/AsyncProfilerTask.java | 3 +-- .../asyncprofiler/AsyncProfilerTaskExecutionService.java | 8 +++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/asyncprofiler/AsyncProfilerTask.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/asyncprofiler/AsyncProfilerTask.java index 6e67d7be58..819b25f998 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/asyncprofiler/AsyncProfilerTask.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/asyncprofiler/AsyncProfilerTask.java @@ -58,8 +58,7 @@ public class AsyncProfilerTask { private static String execute(AsyncProfiler asyncProfiler, String args) throws IllegalArgumentException, IOException { LOGGER.info("async profiler execute args:{}", args); - String result = asyncProfiler.execute(args); - return result.trim(); + return asyncProfiler.execute(args); } /** diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/asyncprofiler/AsyncProfilerTaskExecutionService.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/asyncprofiler/AsyncProfilerTaskExecutionService.java index 18ed922443..da0d350e21 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/asyncprofiler/AsyncProfilerTaskExecutionService.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/asyncprofiler/AsyncProfilerTaskExecutionService.java @@ -43,7 +43,7 @@ public class AsyncProfilerTaskExecutionService implements BootService { private static final AsyncProfiler ASYNC_PROFILER = AsyncProfiler.getInstance(); - private static final String SUCCESS_RESULT = "Profiling started"; + private static final String SUCCESS_RESULT = "Profiling started\n"; // profile executor thread pool, only running one thread private static final ScheduledExecutorService ASYNC_PROFILER_EXECUTOR = Executors.newSingleThreadScheduledExecutor( @@ -133,8 +133,10 @@ public void onComplete() throws Throwable { @Override public void shutdown() throws Throwable { - scheduledFuture.cancel(true); ASYNC_PROFILER_EXECUTOR.shutdown(); - scheduledFuture = null; + if (Objects.nonNull(scheduledFuture)) { + scheduledFuture.cancel(true); + scheduledFuture = null; + } } }