You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by cr...@apache.org on 2025/09/22 09:22:05 UTC
(iotdb) branch wx_remove_reflections created (now f6ec503dfc8)
This is an automated email from the ASF dual-hosted git repository.
critas pushed a change to branch wx_remove_reflections
in repository https://gitbox.apache.org/repos/asf/iotdb.git
at f6ec503dfc8 remove org.reflections:reflections, only test use it
This branch includes the following new commits:
new f6ec503dfc8 remove org.reflections:reflections, only test use it
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(iotdb) 01/01: remove org.reflections:reflections, only test use it
Posted by cr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
critas pushed a commit to branch wx_remove_reflections
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit f6ec503dfc86d249f6adb7223cdde466fcbac6bd
Author: CritasWang <cr...@outlook.com>
AuthorDate: Mon Sep 22 17:21:51 2025 +0800
remove org.reflections:reflections, only test use it
---
.../pipe/annotation/PipePluginAnnotationTest.java | 11 +++++++++-
iotdb-core/datanode/pom.xml | 7 ++++++
.../schemaregion/SchemaRegionLoader.java | 18 ++++++----------
.../mtree/loader/MNodeFactoryLoader.java | 25 ++++++++++------------
.../annotation/PipePluginAnnotationTest.java | 11 +++++++++-
iotdb-core/node-commons/pom.xml | 1 +
.../visibility/VisibilityTestUtils.java | 10 ++-------
.../annotation/PipePluginAnnotationTest.java | 11 +++++++++-
pom.xml | 1 +
9 files changed, 58 insertions(+), 37 deletions(-)
diff --git a/iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/pipe/annotation/PipePluginAnnotationTest.java b/iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/pipe/annotation/PipePluginAnnotationTest.java
index 1cd3adb8f0e..b9936dbff25 100644
--- a/iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/pipe/annotation/PipePluginAnnotationTest.java
+++ b/iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/pipe/annotation/PipePluginAnnotationTest.java
@@ -21,8 +21,13 @@ package org.apache.iotdb.confignode.pipe.annotation;
import org.apache.iotdb.commons.pipe.datastructure.result.Result;
import org.apache.iotdb.commons.pipe.datastructure.visibility.VisibilityTestUtils;
+import org.apache.iotdb.pipe.api.PipePlugin;
import org.junit.Test;
+import org.reflections.Reflections;
+import org.reflections.scanners.SubTypesScanner;
+
+import java.util.Set;
import static org.junit.Assert.fail;
@@ -30,8 +35,12 @@ public class PipePluginAnnotationTest {
@Test
public void testPipePluginVisibility() {
+ // Use the Reflections library to scan the classpath
+ final Reflections reflections =
+ new Reflections("org.apache.iotdb.confignode", new SubTypesScanner(false));
+ final Set<Class<? extends PipePlugin>> subTypes = reflections.getSubTypesOf(PipePlugin.class);
final Result<Void, String> result =
- VisibilityTestUtils.testVisibilityCompatibilityEntry("org.apache.iotdb.confignode");
+ VisibilityTestUtils.testVisibilityCompatibilityEntry(subTypes);
if (result.isErr()) {
fail(result.getErr());
}
diff --git a/iotdb-core/datanode/pom.xml b/iotdb-core/datanode/pom.xml
index ebb1b2807f1..490780a87a7 100644
--- a/iotdb-core/datanode/pom.xml
+++ b/iotdb-core/datanode/pom.xml
@@ -262,6 +262,13 @@
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.javassist</groupId>
+ <artifactId>javassist</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/SchemaRegionLoader.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/SchemaRegionLoader.java
index 5d47acfda5c..e702b1e18c7 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/SchemaRegionLoader.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/SchemaRegionLoader.java
@@ -21,16 +21,17 @@ package org.apache.iotdb.db.schemaengine.schemaregion;
import org.apache.iotdb.commons.exception.MetadataException;
import org.apache.iotdb.commons.schema.SchemaConstant;
+import org.apache.iotdb.db.schemaengine.schemaregion.impl.SchemaRegionMemoryImpl;
+import org.apache.iotdb.db.schemaengine.schemaregion.impl.SchemaRegionPBTreeImpl;
import org.apache.iotdb.db.schemaengine.schemaregion.mtree.loader.MNodeFactoryLoader;
-import org.reflections.Reflections;
-import org.reflections.util.ConfigurationBuilder;
-import org.reflections.util.FilterBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
+import java.util.Arrays;
+import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
@@ -38,8 +39,6 @@ import java.util.concurrent.ConcurrentHashMap;
public class SchemaRegionLoader {
private static final Logger logger = LoggerFactory.getLogger(SchemaRegionLoader.class);
- private static final String PACKAGE_NAME = "org.apache.iotdb.db.schemaengine";
-
private final Map<String, Constructor<ISchemaRegion>> constructorMap = new ConcurrentHashMap<>();
private String currentMode;
@@ -48,13 +47,8 @@ public class SchemaRegionLoader {
@SuppressWarnings("unchecked")
public SchemaRegionLoader() {
- Reflections reflections =
- new Reflections(
- new ConfigurationBuilder()
- .forPackages(PACKAGE_NAME)
- .filterInputsBy(new FilterBuilder().includePackage(PACKAGE_NAME)));
-
- Set<Class<?>> annotatedSchemaRegionSet = reflections.getTypesAnnotatedWith(SchemaRegion.class);
+ Set<Class<?>> annotatedSchemaRegionSet =
+ new HashSet<>(Arrays.asList(SchemaRegionMemoryImpl.class, SchemaRegionPBTreeImpl.class));
for (Class<?> annotatedSchemaRegion : annotatedSchemaRegionSet) {
boolean isSchemaRegion = false;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/loader/MNodeFactoryLoader.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/loader/MNodeFactoryLoader.java
index 9e0fe8c2b7d..47c44d6ee6e 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/loader/MNodeFactoryLoader.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/loader/MNodeFactoryLoader.java
@@ -24,21 +24,18 @@ import org.apache.iotdb.commons.schema.SchemaConstant;
import org.apache.iotdb.commons.schema.node.utils.IMNodeFactory;
import org.apache.iotdb.commons.schema.node.utils.MNodeFactory;
import org.apache.iotdb.db.schemaengine.schemaregion.mtree.impl.mem.mnode.IMemMNode;
+import org.apache.iotdb.db.schemaengine.schemaregion.mtree.impl.mem.mnode.factory.MemMNodeFactory;
import org.apache.iotdb.db.schemaengine.schemaregion.mtree.impl.pbtree.mnode.ICachedMNode;
-
-import org.reflections.Reflections;
-import org.reflections.util.ConfigurationBuilder;
+import org.apache.iotdb.db.schemaengine.schemaregion.mtree.impl.pbtree.mnode.factory.CacheMNodeFactory;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.HashSet;
import java.util.Set;
@SuppressWarnings({"squid:S6548", "squid:3077"})
public class MNodeFactoryLoader {
- private final List<String> scanPackages = new ArrayList<>();
private String env;
@SuppressWarnings("java:S3077")
@@ -47,14 +44,17 @@ public class MNodeFactoryLoader {
@SuppressWarnings("java:S3077")
private volatile IMNodeFactory<IMemMNode> memMNodeIMNodeFactory;
+ private Set<Class<?>> nodeFactorySet;
+
private MNodeFactoryLoader() {
- addScanPackage("org.apache.iotdb.db.schemaengine.schemaregion.mtree.impl.pbtree.mnode.factory");
- addScanPackage("org.apache.iotdb.db.schemaengine.schemaregion.mtree.impl.mem.mnode.factory");
+ nodeFactorySet = new HashSet<>();
+ addNodeFactory(MemMNodeFactory.class);
+ addNodeFactory(CacheMNodeFactory.class);
setEnv(SchemaConstant.DEFAULT_MNODE_FACTORY_ENV);
}
- public void addScanPackage(String scanPackage) {
- scanPackages.add(scanPackage);
+ public void addNodeFactory(Class<?> clazz) {
+ nodeFactorySet.add(clazz);
}
public void setEnv(String env) {
@@ -87,10 +87,7 @@ public class MNodeFactoryLoader {
@SuppressWarnings("squid:S3740")
private IMNodeFactory loadMNodeFactory(Class<?> nodeType) {
- Reflections reflections =
- new Reflections(
- new ConfigurationBuilder().forPackages(scanPackages.toArray(new String[0])));
- Set<Class<?>> nodeFactorySet = reflections.getTypesAnnotatedWith(MNodeFactory.class);
+
for (Class<?> nodeFactory : nodeFactorySet) {
if (isGenericMatch(nodeFactory, nodeType) && isEnvMatch(nodeFactory, env)) {
try {
diff --git a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/pipe/plugin/annotation/PipePluginAnnotationTest.java b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/pipe/plugin/annotation/PipePluginAnnotationTest.java
index a1c78e499d6..5f936b7dd2d 100644
--- a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/pipe/plugin/annotation/PipePluginAnnotationTest.java
+++ b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/pipe/plugin/annotation/PipePluginAnnotationTest.java
@@ -21,8 +21,13 @@ package org.apache.iotdb.db.pipe.plugin.annotation;
import org.apache.iotdb.commons.pipe.datastructure.result.Result;
import org.apache.iotdb.commons.pipe.datastructure.visibility.VisibilityTestUtils;
+import org.apache.iotdb.pipe.api.PipePlugin;
import org.junit.Test;
+import org.reflections.Reflections;
+import org.reflections.scanners.SubTypesScanner;
+
+import java.util.Set;
import static org.junit.Assert.fail;
@@ -30,8 +35,12 @@ public class PipePluginAnnotationTest {
@Test
public void testPipePluginVisibility() {
+ // Use the Reflections library to scan the classpath
+ final Reflections reflections =
+ new Reflections("org.apache.iotdb.db", new SubTypesScanner(false));
+ final Set<Class<? extends PipePlugin>> subTypes = reflections.getSubTypesOf(PipePlugin.class);
final Result<Void, String> result =
- VisibilityTestUtils.testVisibilityCompatibilityEntry("org.apache.iotdb.db");
+ VisibilityTestUtils.testVisibilityCompatibilityEntry(subTypes);
if (result.isErr()) {
fail(result.getErr());
}
diff --git a/iotdb-core/node-commons/pom.xml b/iotdb-core/node-commons/pom.xml
index 91ea3e6e079..5c5cf963a9c 100644
--- a/iotdb-core/node-commons/pom.xml
+++ b/iotdb-core/node-commons/pom.xml
@@ -170,6 +170,7 @@
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.checkerframework</groupId>
diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/pipe/datastructure/visibility/VisibilityTestUtils.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/pipe/datastructure/visibility/VisibilityTestUtils.java
index 14e268152e6..1fc25d4c048 100644
--- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/pipe/datastructure/visibility/VisibilityTestUtils.java
+++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/pipe/datastructure/visibility/VisibilityTestUtils.java
@@ -22,20 +22,14 @@ package org.apache.iotdb.commons.pipe.datastructure.visibility;
import org.apache.iotdb.commons.pipe.datastructure.result.Result;
import org.apache.iotdb.pipe.api.PipePlugin;
-import org.reflections.Reflections;
-import org.reflections.scanners.SubTypesScanner;
-
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
public class VisibilityTestUtils {
- public static Result<Void, String> testVisibilityCompatibilityEntry(final String prefix) {
- // Use the Reflections library to scan the classpath
- final Reflections reflections = new Reflections(prefix, new SubTypesScanner(false));
- final Set<Class<? extends PipePlugin>> subTypes = reflections.getSubTypesOf(PipePlugin.class);
-
+ public static Result<Void, String> testVisibilityCompatibilityEntry(
+ final Set<Class<? extends PipePlugin>> subTypes) {
// Create root node
final TreeNode root = new TreeNode(PipePlugin.class);
diff --git a/iotdb-core/node-commons/src/test/java/org/apache/iotdb/commons/pipe/plugin/annotation/PipePluginAnnotationTest.java b/iotdb-core/node-commons/src/test/java/org/apache/iotdb/commons/pipe/plugin/annotation/PipePluginAnnotationTest.java
index da693b1d4ab..69da43ad4b0 100644
--- a/iotdb-core/node-commons/src/test/java/org/apache/iotdb/commons/pipe/plugin/annotation/PipePluginAnnotationTest.java
+++ b/iotdb-core/node-commons/src/test/java/org/apache/iotdb/commons/pipe/plugin/annotation/PipePluginAnnotationTest.java
@@ -21,8 +21,13 @@ package org.apache.iotdb.commons.pipe.plugin.annotation;
import org.apache.iotdb.commons.pipe.datastructure.result.Result;
import org.apache.iotdb.commons.pipe.datastructure.visibility.VisibilityTestUtils;
+import org.apache.iotdb.pipe.api.PipePlugin;
import org.junit.Test;
+import org.reflections.Reflections;
+import org.reflections.scanners.SubTypesScanner;
+
+import java.util.Set;
import static org.junit.Assert.fail;
@@ -30,8 +35,12 @@ public class PipePluginAnnotationTest {
@Test
public void testPipePluginVisibility() {
+ // Use the Reflections library to scan the classpath
+ final Reflections reflections =
+ new Reflections("org.apache.iotdb.commons", new SubTypesScanner(false));
+ final Set<Class<? extends PipePlugin>> subTypes = reflections.getSubTypesOf(PipePlugin.class);
final Result<Void, String> result =
- VisibilityTestUtils.testVisibilityCompatibilityEntry("org.apache.iotdb.commons");
+ VisibilityTestUtils.testVisibilityCompatibilityEntry(subTypes);
if (result.isErr()) {
fail(result.getErr());
}
diff --git a/pom.xml b/pom.xml
index 17d634cf07f..dd35c7987f0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -443,6 +443,7 @@
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>${reflections.version}</version>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.moquette-io.moquette</groupId>