You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ji...@apache.org on 2026/01/29 10:13:31 UTC

(iotdb) branch add_mustoverride_check created (now a425f186584)

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

jiangtian pushed a change to branch add_mustoverride_check
in repository https://gitbox.apache.org/repos/asf/iotdb.git


      at a425f186584 Add must override check

This branch includes the following new commits:

     new a425f186584 Add must override check

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: Add must override check

Posted by ji...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jiangtian pushed a commit to branch add_mustoverride_check
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit a425f1865846954aa523f40bfa344a4cd07244f4
Author: Tian Jiang <jt...@163.com>
AuthorDate: Thu Jan 29 18:13:14 2026 +0800

    Add must override check
---
 .../org/apache/iotdb/db/utils/AnnotationTest.java  | 59 ++++++++++++++++++++++
 pom.xml                                            |  2 +-
 2 files changed, 60 insertions(+), 1 deletion(-)

diff --git a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/utils/AnnotationTest.java b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/utils/AnnotationTest.java
index 91ae2097089..9594ab6cdcb 100644
--- a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/utils/AnnotationTest.java
+++ b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/utils/AnnotationTest.java
@@ -23,15 +23,20 @@ import org.apache.iotdb.commons.utils.TestOnly;
 
 import com.tngtech.archunit.core.domain.JavaClass;
 import com.tngtech.archunit.core.domain.JavaClasses;
+import com.tngtech.archunit.core.domain.JavaMethod;
 import com.tngtech.archunit.core.domain.properties.CanBeAnnotated;
 import com.tngtech.archunit.core.importer.ClassFileImporter;
 import com.tngtech.archunit.core.importer.ImportOption;
 import com.tngtech.archunit.core.importer.ImportOption.DoNotIncludeTests;
 import com.tngtech.archunit.lang.ArchRule;
+import org.apache.tsfile.utils.MustOverride;
 import org.junit.Test;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
 
 import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.methods;
 
@@ -71,4 +76,58 @@ public class AnnotationTest {
     } catch (OutOfMemoryError ignored) {
     }
   }
+
+  @Test
+  public void checkMustOverride() {
+    try {
+      JavaClasses productionClasses =
+          new ClassFileImporter()
+              .withImportOption(new DoNotIncludeTests())
+              .importPackages("org.apache.iotdb", "org.apache.tsfile");
+
+      Map<JavaClass, List<JavaMethod>> classAndMethodsMustOverride = new HashMap<>();
+      for (JavaClass productionClass : productionClasses) {
+        for (JavaMethod method : productionClass.getMethods()) {
+          if (method.isAnnotatedWith(MustOverride.class)) {
+            classAndMethodsMustOverride
+                .computeIfAbsent(productionClass, k -> new ArrayList<>())
+                .add(method);
+          }
+        }
+      }
+
+      List<String> failures = new ArrayList<>();
+      for (JavaClass productionClass : productionClasses) {
+        for (Entry<JavaClass, List<JavaMethod>> entry : classAndMethodsMustOverride.entrySet()) {
+          JavaClass classWithTargetMethod = entry.getKey();
+          if (productionClass.isAssignableTo(classWithTargetMethod.getName())) {
+            List<JavaMethod> classesWithMustOverride = entry.getValue();
+            for (JavaMethod javaMethod : classesWithMustOverride) {
+              boolean methodImplemented = false;
+              for (JavaMethod method : productionClass.getMethods()) {
+                if (method.getName().equals(javaMethod.getName())
+                    && method.getParameters().equals(javaMethod.getParameters())) {
+                  methodImplemented = true;
+                  break;
+                }
+              }
+              if (!methodImplemented) {
+                failures.add(
+                    String.format(
+                        "Class %s does not implement method %s annotated with @MustOverride from class %s",
+                        productionClass.getName(),
+                        javaMethod.getName(),
+                        classWithTargetMethod.getName()));
+              }
+            }
+          }
+        }
+      }
+
+      if (!failures.isEmpty()) {
+        throw new AssertionError(String.join("\n", failures));
+      }
+    } catch (OutOfMemoryError ignored) {
+    }
+  }
 }
diff --git a/pom.xml b/pom.xml
index c3b80202a01..0c3c9f526cb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -173,7 +173,7 @@
         <thrift.version>0.14.1</thrift.version>
         <xz.version>1.9</xz.version>
         <zstd-jni.version>1.5.6-3</zstd-jni.version>
-        <tsfile.version>2.2.1-260115-SNAPSHOT</tsfile.version>
+        <tsfile.version>2.2.1-260129-2-SNAPSHOT</tsfile.version>
     </properties>
     <!--
     if we claim dependencies in dependencyManagement, then we do not claim