You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by du...@apache.org on 2023/05/25 11:39:44 UTC

[shardingsphere] branch master updated: Fix sonar issue of ConstructorAdviceExecutor (#25893)

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

duanzhengqiang 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 61b03e622b5 Fix sonar issue of ConstructorAdviceExecutor (#25893)
61b03e622b5 is described below

commit 61b03e622b51dff37b96e6350f95eb3f14415210
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Thu May 25 19:39:28 2023 +0800

    Fix sonar issue of ConstructorAdviceExecutor (#25893)
---
 .../core/advisor/executor/type/ConstructorAdviceExecutor.java | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/agent/core/src/main/java/org/apache/shardingsphere/agent/core/advisor/executor/type/ConstructorAdviceExecutor.java b/agent/core/src/main/java/org/apache/shardingsphere/agent/core/advisor/executor/type/ConstructorAdviceExecutor.java
index 5752eeb7c30..3d04236a2d0 100644
--- a/agent/core/src/main/java/org/apache/shardingsphere/agent/core/advisor/executor/type/ConstructorAdviceExecutor.java
+++ b/agent/core/src/main/java/org/apache/shardingsphere/agent/core/advisor/executor/type/ConstructorAdviceExecutor.java
@@ -56,12 +56,13 @@ public final class ConstructorAdviceExecutor implements AdviceExecutor {
     @RuntimeType
     public void advice(@This final TargetAdviceObject target, @AllArguments final Object[] args) {
         boolean adviceEnabled = PluginContext.getInstance().isPluginEnabled();
+        if (!adviceEnabled) {
+            return;
+        }
         try {
-            if (adviceEnabled) {
-                for (Entry<String, Collection<ConstructorAdvice>> entry : advices.entrySet()) {
-                    for (ConstructorAdvice each : entry.getValue()) {
-                        each.onConstructor(target, args, entry.getKey());
-                    }
+            for (Entry<String, Collection<ConstructorAdvice>> entry : advices.entrySet()) {
+                for (ConstructorAdvice each : entry.getValue()) {
+                    each.onConstructor(target, args, entry.getKey());
                 }
             }
             // CHECKSTYLE:OFF