From 1d307332d608df10f2bb383ff5db2c72fb492b79 Mon Sep 17 00:00:00 2001 From: scwlkq <89067331+scwlkq@users.noreply.github.com> Date: Sun, 21 Jan 2024 16:13:13 +0800 Subject: [PATCH] [ISSUE #4733] Substitute e.printStackTrace() with log.error() (#4754) * Substitute e.printStackTrace() with log.error() * add exception arg * Modify the wording of the log --- .../org/apache/eventmesh/common/ThreadWrapperTest.java | 7 +++++-- .../org/apache/eventmesh/openconnect/SourceWorker.java | 5 ++--- .../eventmesh/runtime/client/impl/PubClientImpl.java | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/eventmesh-common/src/test/java/org/apache/eventmesh/common/ThreadWrapperTest.java b/eventmesh-common/src/test/java/org/apache/eventmesh/common/ThreadWrapperTest.java index 6315911eb8..a4f2a60f73 100644 --- a/eventmesh-common/src/test/java/org/apache/eventmesh/common/ThreadWrapperTest.java +++ b/eventmesh-common/src/test/java/org/apache/eventmesh/common/ThreadWrapperTest.java @@ -24,6 +24,9 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Timeout; +import lombok.extern.slf4j.Slf4j; + +@Slf4j public class ThreadWrapperTest { @Test @@ -74,7 +77,7 @@ public void run() { try { TimeUnit.MILLISECONDS.sleep(500); } catch (InterruptedException e) { - e.printStackTrace(); + log.error("[ThreadWrapperTest][shutdown] InterruptedException", e); } counter.set(100); } @@ -136,4 +139,4 @@ public void run() { wrapper.setDaemon(daemon); return wrapper; } -} \ No newline at end of file +} diff --git a/eventmesh-openconnect/eventmesh-openconnect-java/src/main/java/org/apache/eventmesh/openconnect/SourceWorker.java b/eventmesh-openconnect/eventmesh-openconnect-java/src/main/java/org/apache/eventmesh/openconnect/SourceWorker.java index bf9878e486..c5d4fe2b07 100644 --- a/eventmesh-openconnect/eventmesh-openconnect-java/src/main/java/org/apache/eventmesh/openconnect/SourceWorker.java +++ b/eventmesh-openconnect/eventmesh-openconnect-java/src/main/java/org/apache/eventmesh/openconnect/SourceWorker.java @@ -276,7 +276,6 @@ public void stop() { try { source.stop(); } catch (Exception e) { - e.printStackTrace(); log.error("source destroy error", e); } log.info("pollService stopping"); @@ -330,7 +329,7 @@ public boolean commitOffsets() { log.info("{} Committing offsets for {} acknowledged messages", this, committableOffsets.numCommittableMessages()); if (committableOffsets.hasPending()) { log.debug("{} There are currently {} pending messages spread across {} source partitions whose offsets will not be committed. " - + "The source partition with the most pending messages is {}, with {} pending messages", + + "The source partition with the most pending messages is {}, with {} pending messages", this, committableOffsets.numUncommittableMessages(), committableOffsets.numDeques(), @@ -338,7 +337,7 @@ public boolean commitOffsets() { committableOffsets.largestDequeSize()); } else { log.debug("{} There are currently no pending messages for this offset commit; " - + "all messages dispatched to the task's producer since the last commit have been acknowledged", + + "all messages dispatched to the task's producer since the last commit have been acknowledged", this); } } diff --git a/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/client/impl/PubClientImpl.java b/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/client/impl/PubClientImpl.java index 734ad6fc54..cb6cf5dabe 100644 --- a/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/client/impl/PubClientImpl.java +++ b/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/client/impl/PubClientImpl.java @@ -73,7 +73,7 @@ public void close() { task.cancel(false); super.close(); } catch (Exception e) { - e.printStackTrace(); + log.error("PubClientImpl|{}|close failed!", clientNo, e); } }