This is an automated email from the ASF dual-hosted git repository.

terrymanu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new 299926f1bae Fix wrong target class name in StaticMethodAdviceExecutor 
error logs (#39077)
299926f1bae is described below

commit 299926f1bae87123f75cdf31e27245b06b758f8f
Author: Eunbin Son <[email protected]>
AuthorDate: Mon Jul 13 20:55:15 2026 +0900

    Fix wrong target class name in StaticMethodAdviceExecutor error logs 
(#39077)
    
    * Fix wrong target class name in StaticMethodAdviceExecutor error logs
    
    * Fill actual PR number in Release Notes
---
 RELEASE-NOTES.md                                   |  1 +
 .../executor/type/StaticMethodAdviceExecutor.java  |  6 +-
 .../type/StaticMethodAdviceExecutorTest.java       | 84 ++++++++++++++++++++++
 3 files changed, 88 insertions(+), 3 deletions(-)

diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md
index 863215e80fa..487a3a7b786 100644
--- a/RELEASE-NOTES.md
+++ b/RELEASE-NOTES.md
@@ -39,6 +39,7 @@
 1. DistSQL: Fix case-sensitive storage unit matching in `SHOW RULES USED 
STORAGE UNIT` - [#38848](https://github.com/apache/shardingsphere/pull/38848)
 1. Sharding: Compute the Snowflake key generator epoch in UTC instead of the 
JVM default timezone - 
[#38932](https://github.com/apache/shardingsphere/pull/38932)
 1. Proxy: Fix MySQL BLOB data corruption when string-like prepared statement 
parameters target BLOB columns - 
[#39072](https://github.com/apache/shardingsphere/pull/39072)
+1. Agent: Fix wrong target class name in StaticMethodAdviceExecutor error logs 
- [#39077](https://github.com/apache/shardingsphere/pull/39077)
 
 ### Enhancements
 
diff --git 
a/agent/core/src/main/java/org/apache/shardingsphere/agent/core/advisor/executor/type/StaticMethodAdviceExecutor.java
 
b/agent/core/src/main/java/org/apache/shardingsphere/agent/core/advisor/executor/type/StaticMethodAdviceExecutor.java
index c3e7d717628..221ef9acae7 100644
--- 
a/agent/core/src/main/java/org/apache/shardingsphere/agent/core/advisor/executor/type/StaticMethodAdviceExecutor.java
+++ 
b/agent/core/src/main/java/org/apache/shardingsphere/agent/core/advisor/executor/type/StaticMethodAdviceExecutor.java
@@ -89,7 +89,7 @@ public final class StaticMethodAdviceExecutor implements 
AdviceExecutor {
             // CHECKSTYLE:OFF
         } catch (final Throwable ex) {
             // CHECKSTYLE:ON
-            LOGGER.log(Level.SEVERE, "Failed to execute the pre-method of 
method `{0}` in class `{1}`, {2}.", new String[]{method.getName(), 
klass.getClass().getName(), ex.getMessage()});
+            LOGGER.log(Level.SEVERE, "Failed to execute the pre-method of 
method `{0}` in class `{1}`, {2}.", new String[]{method.getName(), 
klass.getName(), ex.getMessage()});
         }
     }
     
@@ -105,7 +105,7 @@ public final class StaticMethodAdviceExecutor implements 
AdviceExecutor {
             // CHECKSTYLE:OFF
         } catch (final Throwable ignored) {
             // CHECKSTYLE:ON
-            LOGGER.log(Level.SEVERE, "Failed to execute the error handler of 
method `{0}` in class `{1}`, {2}.", new String[]{method.getName(), 
klass.getClass().getName(), ex.getMessage()});
+            LOGGER.log(Level.SEVERE, "Failed to execute the error handler of 
method `{0}` in class `{1}`, {2}.", new String[]{method.getName(), 
klass.getName(), ex.getMessage()});
         }
     }
     
@@ -121,7 +121,7 @@ public final class StaticMethodAdviceExecutor implements 
AdviceExecutor {
             // CHECKSTYLE:OFF
         } catch (final Throwable ex) {
             // CHECKSTYLE:ON
-            LOGGER.log(Level.SEVERE, "Failed to execute the post-method of 
method `{0}` in class `{1}` {2}.", new String[]{method.getName(), 
klass.getClass().getName(), ex.getMessage()});
+            LOGGER.log(Level.SEVERE, "Failed to execute the post-method of 
method `{0}` in class `{1}` {2}.", new String[]{method.getName(), 
klass.getName(), ex.getMessage()});
         }
     }
     
diff --git 
a/agent/core/src/test/java/org/apache/shardingsphere/agent/core/advisor/executor/type/StaticMethodAdviceExecutorTest.java
 
b/agent/core/src/test/java/org/apache/shardingsphere/agent/core/advisor/executor/type/StaticMethodAdviceExecutorTest.java
index e3fb293adb9..a8c85cbfe23 100644
--- 
a/agent/core/src/test/java/org/apache/shardingsphere/agent/core/advisor/executor/type/StaticMethodAdviceExecutorTest.java
+++ 
b/agent/core/src/test/java/org/apache/shardingsphere/agent/core/advisor/executor/type/StaticMethodAdviceExecutorTest.java
@@ -38,6 +38,9 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.Callable;
+import java.util.logging.Handler;
+import java.util.logging.LogRecord;
+import java.util.logging.Logger;
 
 import static org.hamcrest.Matchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
@@ -129,6 +132,68 @@ class StaticMethodAdviceExecutorTest {
         assertThat(queue, is(Arrays.asList("first before foo", "second before 
bar", "origin call")));
     }
     
+    @Test
+    void assertAdviceLogsTargetClassNameWhenBeforeThrows() throws 
ReflectiveOperationException {
+        List<String> queue = new LinkedList<>();
+        Map<String, Collection<StaticMethodAdvice>> advices = 
Collections.singletonMap(
+                "foo", Collections.singletonList(new 
ConfigurableStaticMethodAdvice(queue, "first", true, true, false, false)));
+        StaticMethodAdviceExecutor executor = new 
StaticMethodAdviceExecutor(advices);
+        Method method = TargetObjectFixture.class.getMethod("staticCall", 
List.class);
+        Callable<Object> callable = () -> "result";
+        List<LogRecord> records = new LinkedList<>();
+        Logger logger = 
Logger.getLogger(StaticMethodAdviceExecutor.class.getName());
+        Handler handler = new RecordingHandler(records);
+        logger.addHandler(handler);
+        try {
+            executor.advice(TargetObjectFixture.class, method, new 
Object[]{queue}, callable);
+            assertThat(records.get(0).getParameters()[1], 
is(TargetObjectFixture.class.getName()));
+        } finally {
+            logger.removeHandler(handler);
+        }
+    }
+    
+    @Test
+    void assertAdviceLogsTargetClassNameWhenThrowingThrows() throws 
ReflectiveOperationException {
+        List<String> queue = new LinkedList<>();
+        Map<String, Collection<StaticMethodAdvice>> advices = 
Collections.singletonMap(
+                "foo", Collections.singletonList(new 
ConfigurableStaticMethodAdvice(queue, "first", true, false, false, true)));
+        StaticMethodAdviceExecutor executor = new 
StaticMethodAdviceExecutor(advices);
+        Method method = 
TargetObjectFixture.class.getMethod("staticCallWhenExceptionThrown", 
List.class);
+        Callable<Object> callable = () -> {
+            throw new IllegalStateException("callable error");
+        };
+        List<LogRecord> records = new LinkedList<>();
+        Logger logger = 
Logger.getLogger(StaticMethodAdviceExecutor.class.getName());
+        Handler handler = new RecordingHandler(records);
+        logger.addHandler(handler);
+        try {
+            assertThrows(IllegalStateException.class, () -> 
executor.advice(TargetObjectFixture.class, method, new Object[]{queue}, 
callable));
+            assertThat(records.get(0).getParameters()[1], 
is(TargetObjectFixture.class.getName()));
+        } finally {
+            logger.removeHandler(handler);
+        }
+    }
+    
+    @Test
+    void assertAdviceLogsTargetClassNameWhenAfterThrows() throws 
ReflectiveOperationException {
+        List<String> queue = new LinkedList<>();
+        Map<String, Collection<StaticMethodAdvice>> advices = 
Collections.singletonMap(
+                "foo", Collections.singletonList(new 
ConfigurableStaticMethodAdvice(queue, "first", true, false, true, false)));
+        StaticMethodAdviceExecutor executor = new 
StaticMethodAdviceExecutor(advices);
+        Method method = TargetObjectFixture.class.getMethod("staticCall", 
List.class);
+        Callable<Object> callable = () -> "result";
+        List<LogRecord> records = new LinkedList<>();
+        Logger logger = 
Logger.getLogger(StaticMethodAdviceExecutor.class.getName());
+        Handler handler = new RecordingHandler(records);
+        logger.addHandler(handler);
+        try {
+            executor.advice(TargetObjectFixture.class, method, new 
Object[]{queue}, callable);
+            assertThat(records.get(0).getParameters()[1], 
is(TargetObjectFixture.class.getName()));
+        } finally {
+            logger.removeHandler(handler);
+        }
+    }
+    
     @SuppressWarnings({"unchecked", "rawtypes"})
     @Test
     void assertIntercept() {
@@ -142,6 +207,25 @@ class StaticMethodAdviceExecutorTest {
         assertThat(executor.intercept(builder, methodDescription), 
is(intercepted));
     }
     
+    @RequiredArgsConstructor
+    private static final class RecordingHandler extends Handler {
+        
+        private final List<LogRecord> records;
+        
+        @Override
+        public void publish(final LogRecord record) {
+            records.add(record);
+        }
+        
+        @Override
+        public void flush() {
+        }
+        
+        @Override
+        public void close() {
+        }
+    }
+    
     @RequiredArgsConstructor
     private static final class RecordingStaticMethodAdvice implements 
StaticMethodAdvice {
         

Reply via email to