diff --git a/fluss-server/src/test/java/org/apache/fluss/server/RpcServiceBaseTest.java b/fluss-server/src/test/java/org/apache/fluss/server/RpcServiceBaseTest.java new file mode 100644 index 0000000000..e2da7a0030 --- /dev/null +++ b/fluss-server/src/test/java/org/apache/fluss/server/RpcServiceBaseTest.java @@ -0,0 +1,167 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.fluss.server; + +import org.junit.jupiter.api.Test; + +import java.io.IOException; +import java.nio.file.FileVisitResult; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.SimpleFileVisitor; +import java.nio.file.attribute.BasicFileAttributes; +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * A meta-test for {@link RpcServiceBase} and related server-side catalog/coordinator code. + * + *
This test scans all Java source files under {@code fluss-server/src/main/java} to detect
+ * patterns where a {@code catch} block catches an exception variable but throws a new exception
+ * without passing the caught variable as the cause. This helps prevent loss of root-cause
+ * information in exception chains.
+ */
+class RpcServiceBaseTest {
+
+ private static final Path SERVER_SOURCE_DIR =
+ Paths.get("src/main/java/org/apache/fluss/server");
+
+ private static final Pattern CATCH_PATTERN =
+ Pattern.compile("\\s*catch\\s*\\(\\s*\\w+(?:\\.\\w+)*\\s+(\\w+)\\s*\\)\\s*\\{?");
+
+ private static final Pattern THROW_NEW_PATTERN =
+ Pattern.compile("throw\\s+new\\s+\\w+Exception\\s*\\(");
+
+ @Test
+ void metaTestNoCatchRethrowWithoutCause() throws IOException {
+ assertThat(Files.exists(SERVER_SOURCE_DIR))
+ .as("Server source directory must exist: " + SERVER_SOURCE_DIR.toAbsolutePath())
+ .isTrue();
+
+ List