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; + } } }