You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2022/12/11 06:40:26 UTC
[shardingsphere] branch master updated: Add private constructor for AdviceInstanceLoader (#22798)
This is an automated email from the ASF dual-hosted git repository.
zhaojinchao 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 5277ce3b19a Add private constructor for AdviceInstanceLoader (#22798)
5277ce3b19a is described below
commit 5277ce3b19a3c3d66313affd08db894848aff0c1
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Sun Dec 11 14:40:20 2022 +0800
Add private constructor for AdviceInstanceLoader (#22798)
* Rename StaticMethodAroundAdvice
* Add private constructor for AdviceInstanceLoader
* Add private constructor for AdviceInstanceLoader
---
.../shardingsphere/agent/core/plugin/AdviceInstanceLoader.java | 7 +++++--
.../core/bytebuddy/transformer/ShardingSphereTransformerTest.java | 4 +---
.../agent/core/plugin/loader/AgentPluginLoaderTest.java | 4 +---
3 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/agent/core/src/main/java/org/apache/shardingsphere/agent/core/plugin/AdviceInstanceLoader.java b/agent/core/src/main/java/org/apache/shardingsphere/agent/core/plugin/AdviceInstanceLoader.java
index 3a071a0d820..8f533690d16 100644
--- a/agent/core/src/main/java/org/apache/shardingsphere/agent/core/plugin/AdviceInstanceLoader.java
+++ b/agent/core/src/main/java/org/apache/shardingsphere/agent/core/plugin/AdviceInstanceLoader.java
@@ -17,6 +17,8 @@
package org.apache.shardingsphere.agent.core.plugin;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
import lombok.SneakyThrows;
import org.apache.shardingsphere.agent.config.AgentConfiguration;
import org.apache.shardingsphere.agent.core.common.AgentClassLoader;
@@ -31,11 +33,12 @@ import java.util.concurrent.locks.ReentrantLock;
/**
* Advice instance loader.
*/
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class AdviceInstanceLoader {
- private static final Map<String, Object> ADVICE_INSTANCE_CACHE = new ConcurrentHashMap();
+ private static final Map<String, Object> ADVICE_INSTANCE_CACHE = new ConcurrentHashMap<>();
- private static final Map<ClassLoader, ClassLoader> PLUGIN_CLASSLOADERS = new HashMap();
+ private static final Map<ClassLoader, ClassLoader> PLUGIN_CLASSLOADERS = new HashMap<>();
private static final ReentrantLock INIT_INSTANCE_LOCK = new ReentrantLock();
diff --git a/agent/core/src/test/java/org/apache/shardingsphere/agent/core/bytebuddy/transformer/ShardingSphereTransformerTest.java b/agent/core/src/test/java/org/apache/shardingsphere/agent/core/bytebuddy/transformer/ShardingSphereTransformerTest.java
index 25cfdc01ee2..8d1a46520b5 100644
--- a/agent/core/src/test/java/org/apache/shardingsphere/agent/core/bytebuddy/transformer/ShardingSphereTransformerTest.java
+++ b/agent/core/src/test/java/org/apache/shardingsphere/agent/core/bytebuddy/transformer/ShardingSphereTransformerTest.java
@@ -54,8 +54,6 @@ import static org.junit.Assert.assertArrayEquals;
public final class ShardingSphereTransformerTest {
- private static final AdviceInstanceLoader INSTANCE_LOADER = new AdviceInstanceLoader();
-
private static final AgentPluginLoader PLUGIN_LOADER = new AgentPluginLoader();
private static ResettableClassFileTransformer byteBuddyAgent;
@@ -67,7 +65,7 @@ public final class ShardingSphereTransformerTest {
public static void setup() throws ReflectiveOperationException {
ByteBuddyAgent.install();
AgentClassLoader.initDefaultPluginClassLoader(Collections.emptyList());
- FieldReader objectPoolReader = new FieldReader(INSTANCE_LOADER, INSTANCE_LOADER.getClass().getDeclaredField("ADVICE_INSTANCE_CACHE"));
+ FieldReader objectPoolReader = new FieldReader(AdviceInstanceLoader.class, AdviceInstanceLoader.class.getDeclaredField("ADVICE_INSTANCE_CACHE"));
Map<String, Object> objectPool = (Map<String, Object>) objectPoolReader.read();
objectPool.put(MockConstructorAdvice.class.getTypeName(), new MockConstructorAdvice());
objectPool.put(MockInstanceMethodAroundAdvice.class.getTypeName(), new MockInstanceMethodAroundAdvice());
diff --git a/agent/core/src/test/java/org/apache/shardingsphere/agent/core/plugin/loader/AgentPluginLoaderTest.java b/agent/core/src/test/java/org/apache/shardingsphere/agent/core/plugin/loader/AgentPluginLoaderTest.java
index 1ae8a1165f4..78ab8ce64e7 100644
--- a/agent/core/src/test/java/org/apache/shardingsphere/agent/core/plugin/loader/AgentPluginLoaderTest.java
+++ b/agent/core/src/test/java/org/apache/shardingsphere/agent/core/plugin/loader/AgentPluginLoaderTest.java
@@ -43,8 +43,6 @@ import static org.junit.Assert.assertTrue;
@Category(AgentPluginLoaderTest.class)
public final class AgentPluginLoaderTest {
- private static final AdviceInstanceLoader INSTANCE_LOADER = new AdviceInstanceLoader();
-
private static final AgentPluginLoader PLUGIN_LOADER = new AgentPluginLoader();
private static final TypePool POOL = TypePool.Default.ofSystemLoader();
@@ -56,7 +54,7 @@ public final class AgentPluginLoaderTest {
@BeforeClass
@SuppressWarnings("unchecked")
public static void setup() throws NoSuchFieldException, IllegalAccessException {
- FieldReader objectPoolReader = new FieldReader(INSTANCE_LOADER, INSTANCE_LOADER.getClass().getDeclaredField("ADVICE_INSTANCE_CACHE"));
+ FieldReader objectPoolReader = new FieldReader(AdviceInstanceLoader.class, AdviceInstanceLoader.class.getDeclaredField("ADVICE_INSTANCE_CACHE"));
Map<String, Object> objectPool = (Map<String, Object>) objectPoolReader.read();
objectPool.put(MockConstructorAdvice.class.getTypeName(), new MockConstructorAdvice());
objectPool.put(MockInstanceMethodAroundAdvice.class.getTypeName(), new MockInstanceMethodAroundAdvice());