Skip to content

[Improve][Zeta] Load storage-specific starter jars - #10618

Open
corgy-w wants to merge 8 commits into
apache:devfrom
corgy-w:corgy/storage-specific-zeta-jars
Open

corgy-w wants to merge 8 commits into
apache:devfrom
corgy-w:corgy/storage-specific-zeta-jars

Conversation

@corgy-w

@corgy-w corgy-w commented Mar 18, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

  • load checkpoint and IMAP storage dependencies from starter/zeta/common and storage-specific subdirectories based on plugin-config.storage.type
  • package zeta storage jars into starter/zeta/common, starter/zeta/s3, and starter/zeta/oss for both dist assemblies
  • update English and Chinese checkpoint/deployment docs to describe the new loading behavior

Verify

  • ./mvnw spotless:apply
  • ./mvnw -q -DskipTests verify
  • ./mvnw -pl seatunnel-common -Dtest=FileUtilsTest test

Notes

  • ./mvnw test currently fails in seatunnel-config/seatunnel-config-shade with ClassNotFoundException: org.apache.seatunnel.shade.com.typesafe.config.ConfigFactory before reaching the modified modules

@github-actions github-actions Bot added document core SeaTunnel core module Zeta api labels Mar 18, 2026
@DanielCarter-stack

Copy link
Copy Markdown
Contributor

Issue 1: Null Pointer Risk (CRITICAL)

Location: seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/CheckpointService.java:63

List<URL> storageJars =
        FileUtils.searchJarFilesForStorage(
                Common.appStarterDir().resolve("zeta"),
                config.getStorage().getStoragePluginConfig().get("storage.type"));

Related Context:

  • Parent class/interface: None
  • Caller: CheckpointService constructor
  • Configuration source: CheckpointStorageConfig.storagePluginConfig

Issue Description:
Although the searchJarFilesForStorage method internally handles the case where storageType is null (it will fall back to scanning the entire directory), the chained call config.getStorage().getStoragePluginConfig().get("storage.type") poses risks:

  1. getStorage() may return null (although default values are initialized in CheckpointConfig)
  2. The HashMap returned by getStoragePluginConfig() may be null (although initialized as an empty HashMap)
  3. get("storage.type") returns null when the key does not exist

This coding style reduces code readability and robustness.

Potential Risks:

  • Risk 1: If someone modifies the initialization logic of CheckpointStorageConfig in the future, it could lead to NPE
  • Risk 2: During code review, multiple layers of calls need to be traced to confirm safety

Impact Scope:

  • Direct impact: CheckpointService constructor
  • Indirect impact: All places using CheckpointService (such as JobMaster)
  • Impact area: Core framework

Severity: CRITICAL (Although it won't crash currently, it's a bad practice)

Improvement Suggestions:

// CheckpointService.java
public CheckpointService(CheckpointConfig config) {
    ClassLoader storageClassLoader = Thread.currentThread().getContextClassLoader();
    
    // Safely obtain storage.type
    CheckpointStorageConfig storageConfig = config.getStorage();
    String storageType = null;
    if (storageConfig != null && storageConfig.getStoragePluginConfig() != null) {
        storageType = storageConfig.getStoragePluginConfig().get("storage.type");
    }
    
    List<URL> storageJars =
            FileUtils.searchJarFilesForStorage(
                    Common.appStarterDir().resolve("zeta"),
                    storageType);
    
    if (!storageJars.isEmpty()) {
        storageClassLoader =
                new URLClassLoader(storageJars.toArray(new URL[0]), storageClassLoader);
    }

    try (TemporaryClassLoaderContext ignored =
            TemporaryClassLoaderContext.of(storageClassLoader)) {
        this.checkpointStorage =
                FactoryUtil.discoverFactory(
                                Thread.currentThread().getContextClassLoader(),
                                CheckpointStorageFactory.class,
                                config.getStorage().getStorage())
                        .create(config.getStorage().getStoragePluginConfig());
    }
}

Rationale: Explicitly check each layer that could be null to improve code robustness and readability.


Issue 2: URLClassLoader Not Closed (MAJOR)

Location:

  • seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/CheckpointService.java:65-66
  • seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/persistence/FileMapStore.java:59-60
// CheckpointService.java
if (!storageJars.isEmpty()) {
    storageClassLoader =
            new URLClassLoader(storageJars.toArray(new URL[0]), storageClassLoader);
}

try (TemporaryClassLoaderContext ignored =
        TemporaryClassLoaderContext.of(storageClassLoader)) {
    // ...
}

Related Context:

  • URLClassLoader: Java standard library class for loading classes and resources from URLs
  • TemporaryClassLoaderContext: Existing utility class in the PR for temporarily setting context class loader
  • Caller 1: CheckpointService constructor, called during server startup
  • Caller 2: FileMapStore.init(), called when Hazelcast initializes MapStore

Issue Description:
The created URLClassLoader is not explicitly closed. Although in CheckpointService this classloader will be saved and used long-term (indirectly referenced through the checkpointStorage field), in FileMapStore, if IMapStorage is reinitialized, multiple URLClassLoader may be created without closing the old ones.

Java 7 introduced the URLClassLoader.close() method for releasing resources, including open JAR file handles. Although the JVM will eventually close these file handles during GC, in scenarios where URLClassLoader is created frequently, it may lead to:

  1. File handle leaks (reaching operating system limits)
  2. Memory leaks (Classes loaded by the ClassLoader cannot be GC'd)

Potential Risks:

  • Risk 1: In scenarios of frequent restarts or reinitialization of FileMapStore, it may lead to "too many open files" errors
  • Risk 2: In long-running services, it may cause continuous memory growth
  • Risk 3: In containerized environments, resource limits may be reached more quickly

Impact Scope:

  • Direct impact: CheckpointService, FileMapStore
  • Indirect impact: All jobs using checkpoint or IMAP storage
  • Impact area: Core framework

Severity: MAJOR (Limited impact in normal usage scenarios, but may cause problems in specific scenarios)

Improvement Suggestions:

// CheckpointService.java
public class CheckpointService {
    @Getter
    private CheckpointStorage checkpointStorage;
    private Serializer serializer = new ProtoStuffSerializer();
    private URLClassLoader storageClassLoader; // Save reference for later closing

    @SneakyThrows
    public CheckpointService(CheckpointConfig config) {
        ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader();
        List<URL> storageJars =
                FileUtils.searchJarFilesForStorage(
                        Common.appStarterDir().resolve("zeta"),
                        config.getStorage().getStoragePluginConfig().get("storage.type"));
        
        if (!storageJars.isEmpty()) {
            this.storageClassLoader =
                    new URLClassLoader(storageJars.toArray(new URL[0]), currentClassLoader);
            currentClassLoader = this.storageClassLoader;
        }

        try (TemporaryClassLoaderContext ignored =
                TemporaryClassLoaderContext.of(currentClassLoader)) {
            this.checkpointStorage =
                    FactoryUtil.discoverFactory(
                                    Thread.currentThread().getContextClassLoader(),
                                    CheckpointStorageFactory.class,
                                    config.getStorage().getStorage())
                            .create(config.getStorage().getStoragePluginConfig());
        }
    }
    
    /**
     * Release resources held by this service.
     * Should be called when the service is no longer needed.
     */
    public void close() {
        if (storageClassLoader != null) {
            try {
                storageClassLoader.close();
            } catch (IOException e) {
                log.warn("Failed to close storage classloader", e);
            }
        }
    }
}

For FileMapStore, since Hazelcast's MapStore interface does not define lifecycle methods (except init and destroy), it is recommended to close the classloader in the destroy method:

// FileMapStore.java
public class FileMapStore implements MapStore<Object, Object>, MapLoaderLifecycleSupport {

    private IMapStorage mapStorage;
    private URLClassLoader storageClassLoader; // Save reference

    @Override
    public void init(HazelcastInstance hazelcastInstance, Properties properties, String mapName) {
        Map<String, Object> initMap = new HashMap<>(Maps.fromProperties(properties));
        ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader();
        
        try {
            List<URL> storageJars =
                    FileUtils.searchJarFilesForStorage(
                            Common.appStarterDir().resolve("zeta"),
                            properties.getProperty("storage.type"));
            if (!storageJars.isEmpty()) {
                this.storageClassLoader =
                        new URLClassLoader(storageJars.toArray(new URL[0]), currentClassLoader);
                currentClassLoader = this.storageClassLoader;
            }
        } catch (IOException e) {
            throw new IllegalStateException("Failed to load Zeta storage jars", e);
        }

        try (TemporaryClassLoaderContext ignored =
                TemporaryClassLoaderContext.of(currentClassLoader)) {
            this.mapStorage =
                    FactoryUtil.discoverFactory(
                                    Thread.currentThread().getContextClassLoader(),
                                    IMapStorageFactory.class,
                                    (String) initMap.get("type"))
                        .create(initMap);
        }
    }

    @Override
    public void destroy() {
        // Close mapStorage first
        if (mapStorage != null) {
            mapStorage.destroy(false);
        }
        
        // Then close classloader
        if (storageClassLoader != null) {
            try {
                storageClassLoader.close();
                log.debug("Closed storage classloader for FileMapStore");
            } catch (IOException e) {
                log.warn("Failed to close storage classloader", e);
            }
        }
    }
}

Rationale: Explicitly manage resource lifecycle to avoid resource leaks, which is a best practice for Java resource management.


Issue 3: Path Traversal Risk (MAJOR)

Location: seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:105

String normalizedStorageType = storageType.trim().toLowerCase(Locale.ROOT);
Path storageDir = zetaDirectory.resolve(normalizedStorageType);

Related Context:

  • Parent class/interface: None
  • Caller 1: CheckpointService constructor
  • Caller 2: FileMapStore.init()
  • Data source: User configuration plugin-config.storage.type

Issue Description:
Although the code uses the Path.resolve() method (which normalizes paths), the resolve() method does not prevent path traversal. If storageType contains "../" (such as "../../etc"), resolve() will resolve it to a parent directory path relative to zetaDirectory.

For example:

Path zetaDir = Paths.get("/opt/seatunnel/starter/zeta");
Path storageDir = zetaDir.resolve("../../etc");
// storageDir = /opt/seatunnel/etc

This could lead to malicious configuration accessing arbitrary directories.

Although:

  1. The code only loads .jar files
  2. It will eventually traverse through FileVisitOption.FOLLOW_LINKS

But if an attacker is able to:

  1. Control the storage.type configuration
  2. Place malicious JAR files in accessible directories

Then arbitrary JAR files could be loaded.

Potential Risks:

  • Risk 1: Path traversal attack, accessing arbitrary system directories
  • Risk 2: Information leakage (determining file system structure by checking whether directories exist)
  • Risk 3: Loading malicious JAR files

Impact Scope:

  • Direct impact: FileUtils.searchJarFilesForStorage()
  • Indirect impact: All places using this method
  • Impact area: Core framework

Severity: MAJOR (Requires configuration file tampering to exploit, but still a security risk)

Improvement Suggestions:

// FileUtils.java
public static List<URL> searchJarFilesForStorage(
        @NonNull Path zetaDirectory, String storageType) throws IOException {
    if (!Files.isDirectory(zetaDirectory)) {
        log.debug("Zeta directory does not exist: {}", zetaDirectory);
        return new ArrayList<>();
    }

    if (storageType == null || storageType.trim().isEmpty()) {
        return searchJarFiles(zetaDirectory);
    }

    // Validate the legitimacy of storage type
    String normalizedStorageType = storageType.trim().toLowerCase(Locale.ROOT);
    
    // Add path traversal protection: only allow letters, numbers, underscores, hyphens
    if (!normalizedStorageType.matches("^[a-z0-9_-]+$")) {
        throw new IllegalArgumentException(
                "Invalid storage type: '" + storageType + "'. " +
                "Storage type must contain only letters, numbers, underscores, and hyphens.");
    }
    
    // Verify that the resolved path is still under zetaDirectory
    Path storageDir = zetaDirectory.resolve(normalizedStorageType);
    if (!storageDir.startsWith(zetaDirectory)) {
        throw new IllegalArgumentException(
                "Invalid storage type: '" + storageType + "'. " +
                "Path traversal detected.");
    }

    List<URL> jars = new ArrayList<>();
    boolean splitLayoutDetected = false;

    Path commonDir = zetaDirectory.resolve("common");
    if (Files.isDirectory(commonDir)) {
        splitLayoutDetected = true;
        jars.addAll(searchJarFiles(commonDir));
    }

    if (Files.isDirectory(storageDir)) {
        splitLayoutDetected = true;
        jars.addAll(searchJarFiles(storageDir));
    }

    if (splitLayoutDetected) {
        log.info(
                "Loaded {} storage JAR(s) for storage type '{}' from {}",
                jars.size(),
                normalizedStorageType,
                zetaDirectory);
        return jars;
    }

    log.info(
            "No split Zeta storage directory found for storage type '{}', scan all JAR(s) under {} instead",
            normalizedStorageType,
            zetaDirectory);
    return searchJarFiles(zetaDirectory);
}

Rationale: Defensive programming - even if the risk is low in the current scenario, security best practices should still be followed.


Issue 4: Insufficient Test Coverage (MINOR)

Location: seatunnel-common/src/test/java/org/apache/seatunnel/common/utils/FileUtilsTest.java

Issue Description:
The newly added test cases do not cover the following edge cases:

  1. storageType is null
  2. storageType is an empty string
  3. storageType contains spaces (there are existing tests, but only for leading/trailing spaces)
  4. storageType mixed case (such as "S3", "s3", "S3")
  5. zetaDirectory does not exist
  6. common directory exists but storage directory does not exist
  7. Path traversal attacks (such as "../../etc")
  8. Symbolic links (although the code uses FOLLOW_LINKS)
  9. Invalid characters (such as "s3/../../etc")

Potential Risks:

  • Risk 1: Behavior under edge cases does not meet expectations
  • Risk 2: Regression issues may be introduced during future refactoring

Impact Scope:

  • Direct impact: FileUtils.searchJarFilesForStorage()
  • Impact area: Single utility class

Severity: MINOR (Current logic is simple, but comprehensive testing can improve code quality)

Improvement Suggestions:

// FileUtilsTest.java
@Test
public void testSearchJarFilesForStorageWithNullStorageType() throws Exception {
    Path zetaDir = Files.createTempDirectory("seatunnel-zeta");
    Path jar = Files.createFile(zetaDir.resolve("test.jar"));

    List<URL> urls = FileUtils.searchJarFilesForStorage(zetaDir, null);

    Assertions.assertEquals(1, urls.size());
    Assertions.assertTrue(urls.get(0).toString().contains("test.jar"));
}

@Test
public void testSearchJarFilesForStorageWithEmptyStorageType() throws Exception {
    Path zetaDir = Files.createTempDirectory("seatunnel-zeta");
    Path jar = Files.createFile(zetaDir.resolve("test.jar"));

    List<URL> urls = FileUtils.searchJarFilesForStorage(zetaDir, "   ");

    Assertions.assertEquals(1, urls.size());
}

@Test
public void testSearchJarFilesForStorageCaseInsensitive() throws Exception {
    Path zetaDir = Files.createTempDirectory("seatunnel-zeta");
    Files.createDirectories(zetaDir.resolve("s3"));
    Path jar = Files.createFile(zetaDir.resolve("s3").resolve("s3.jar"));

    // Test various case combinations
    for (String type : Arrays.asList("S3", "s3", "S3", "S 3")) {
        Set<String> jarNames = extractJarNames(
            FileUtils.searchJarFilesForStorage(zetaDir, type));
        Assertions.assertEquals(new HashSet<>(Arrays.asList("s3.jar")), jarNames);
    }
}

@Test
public void testSearchJarFilesForStorageWithNonExistentZetaDirectory() throws Exception {
    Path nonExistentDir = Paths.get("/tmp/seatunnel-non-existent-" + System.nanoTime());

    List<URL> urls = FileUtils.searchJarFilesForStorage(nonExistentDir, "s3");

    Assertions.assertTrue(urls.isEmpty());
}

@Test
public void testSearchJarFilesForStorageWithCommonButNoStorageDir() throws Exception {
    Path zetaDir = Files.createTempDirectory("seatunnel-zeta");
    Files.createDirectories(zetaDir.resolve("common"));
    Path commonJar = Files.createFile(zetaDir.resolve("common").resolve("common.jar"));

    Set<String> jarNames = extractJarNames(
        FileUtils.searchJarFilesForStorage(zetaDir, "s3"));

    Assertions.assertEquals(new HashSet<>(Arrays.asList("common.jar")), jarNames);
}

@Test
public void testSearchJarFilesForStoragePreventsPathTraversal() {
    Path zetaDir = Files.createTempDirectory("seatunnel-zeta");
    
    // Test path traversal attempts
    for (String maliciousType : Arrays.asList("../../etc", "../s3", "s3/../../etc")) {
        Assertions.assertThrows(
            IllegalArgumentException.class,
            () -> FileUtils.searchJarFilesForStorage(zetaDir, maliciousType),
            "Should reject path traversal in storage type: " + maliciousType);
    }
}

Rationale: Improve test coverage to ensure correct behavior under various edge cases.


Issue 5: Missing @SInCE Annotation (MINOR)

Location: seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:84

/**
 * Search Zeta storage JAR files from a split starter layout.
 * ...
 */
public static List<URL> searchJarFilesForStorage(
        @NonNull Path zetaDirectory, String storageType) throws IOException {

Issue Description:
The newly added public API method is missing the @since annotation, making it impossible to trace the version it was introduced in.

Potential Risks:

  • Risk 1: Users cannot know which version this method was introduced in
  • Risk 2: Affects the completeness of API documentation

Impact Scope:

  • Direct impact: FileUtils.searchJarFilesForStorage()
  • Impact area: Public API

Severity: MINOR (Does not affect functionality, but is a documentation standards issue)

Improvement Suggestions:

/**
 * Search Zeta storage JAR files from a split starter layout.
 * ...
 *
 * @since 3.0.0
 */
public static List<URL> searchJarFilesForStorage(
        @NonNull Path zetaDirectory, String storageType) throws IOException {

Rationale: Follow Apache project API documentation standards.


Issue 6: Improper Log Level Usage (MINOR)

Location: seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:120-123

log.info(
        "No split Zeta storage directory found for storage type '{}', scan all JAR(s) under {} instead",
        normalizedStorageType,
        zetaDirectory);

Issue Description:
When falling back to scanning the entire directory due to no split layout being detected, log.info is used. This may indicate:

  1. Configuration error (user configured an unsupported storage type)
  2. Incomplete installation (missing necessary directories)
  3. Old version directory layout being used

In such uncertain situations, log.warn should be used to draw the attention of operations personnel.

Potential Risks:

  • Risk 1: Configuration issues may be overlooked
  • Risk 2: Performance issues may be overlooked (scanning the entire directory is slower than scanning subdirectories)

Impact Scope:

  • Direct impact: Log readability and problem diagnosis
  • Impact area: Operations and troubleshooting

Severity: MINOR (Does not affect functionality, but affects operations experience)

Improvement Suggestions:

log.warn(
        "No split Zeta storage directory found for storage type '{}', " +
        "falling back to scan all JAR(s) under {}. This may indicate a configuration issue " +
        "or incomplete installation. Expected directory structure: {}/common and {}/{}",
        normalizedStorageType,
        zetaDirectory,
        zetaDirectory,
        normalizedStorageType);

Rationale: Using appropriate log levels can help locate problems more quickly.


@corgy-w
corgy-w force-pushed the corgy/storage-specific-zeta-jars branch from eb2aec4 to 7ec3fbd Compare March 22, 2026 13:37
@DanielLeens

Copy link
Copy Markdown
Contributor

Hi @corgy-w, I pulled this PR locally and reviewed the Zeta storage-jar loading path against the current dev baseline.

Local branch: seatunnel-review-10618
Head reviewed: 7ec3fbdf7707933202ebd4b7cad609dde1b5c92e

What this PR fixes:

  • User pain: when checkpoint or IMAP storage uses storage-specific Hadoop integrations such as OSS or S3, the engine needs the matching storage jars available during storage factory discovery and filesystem initialization. Without a dedicated loading path, users either have to put everything into the global lib/ classpath or hit missing-provider / missing-class failures during master startup, map-store initialization, checkpoint restore, or checkpoint listing.
  • Fix approach: the distribution now places common and storage-specific Zeta storage jars under starter/zeta/common, starter/zeta/s3, and starter/zeta/oss; CheckpointService and FileMapStore create a temporary storage-aware classloader before discovering the storage factory.
  • In one sentence: this makes Zeta storage dependency loading explicit and keeps the storage initialization path compatible with both the old flat layout and the new split layout.

Runtime path checked:

Zeta master startup
  -> SeaTunnelServer.startMaster()
      -> new CheckpointService(checkpointConfig)
          -> Common.appStarterDir().resolve("zeta")
          -> FileUtils.searchJarFilesForStorage(..., plugin-config.storage.type)
              -> official split layout: common/ + matching storage type directory
              -> legacy layout: full starter/zeta scan
          -> TemporaryClassLoaderContext.of(storageClassLoader)
          -> FactoryUtil.discoverFactory(..., CheckpointStorageFactory, storage.type)
          -> CheckpointStorageFactory.create(pluginConfig)

Hazelcast IMAP persistence startup
  -> FileMapStore.init(hazelcastInstance, properties, mapName)
      -> storage.type from map-store properties
      -> FileUtils.searchJarFilesForStorage(starter/zeta, storage.type)
      -> TemporaryClassLoaderContext.of(storageClassLoader)
      -> FactoryUtil.discoverFactory(..., IMapStorageFactory, type)
      -> IMapStorageFactory.create(initMap)

Checkpoint use after initialization
  -> JobMaster.initCheckPointManager()
      -> seaTunnelServer.getCheckpointService().getCheckpointStorage()
  -> checkpoint write/restore/list paths use the already-created storage instance

Key local findings:

  • The normal Zeta master path does hit the CheckpointService change at startup, before checkpoint restore/list operations use the storage instance.
  • The normal IMAP map-store path does hit the FileMapStore change when Hazelcast initializes the configured map store.
  • FileUtils.searchJarFilesForStorage() preserves backward compatibility: if the split starter/zeta/common / storage-specific directories do not exist, it falls back to scanning the whole Zeta directory.
  • The docs were updated in both English and Chinese, and the package assembly now includes the new split storage directories.

Local checks performed:

  • git fetch upstream pull/10618/head:seatunnel-review-10618 --force: passed.
  • git checkout seatunnel-review-10618: passed.
  • git diff --stat upstream/dev...seatunnel-review-10618: 13 files, +318/-68.
  • Source-chain inspection covered SeaTunnelServer.startMaster(), CheckpointService, FileMapStore, FileUtils.searchJarFilesForStorage(), the distribution assembly descriptors, and the updated docs.
  • Local build/tests were not run; this was a source-level review. GitHub reports the Build, Notify test workflow, and labeler checks as successful.

Merge conclusion

Conclusion: can merge

Blocking items:

  • None found in this source-level review.

Non-blocking suggestions:

  • If a future PR tries to fully isolate storage-specific dependencies from the global cluster classpath, it should also revisit the cluster startup classpath because seatunnel-cluster.sh still starts the engine with lib/* plus the starter jar.

Overall evaluation:

This is a focused and compatible improvement to the Zeta storage dependency loading path. The implementation keeps the old layout working, updates both checkpoint and IMAP storage initialization, and has green GitHub checks, so I think it is mergeable.

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update. I re-reviewed the complete latest head 037668b66893, including the new storage-specific starter layout, checkpoint/IMAP factory discovery, assembly contents, compatibility fallback, focused classloader tests, and the EN/ZH deployment documentation.

I do not see a source- or diff-integrity blocker on the current 15-file change. The latest commits preserve root-level legacy jars, include the missing Netty common dependency for OSS, and add isolated SPI discovery tests for both checkpoint and IMAP storage. The earlier test-coverage concern is resolved; the defensive null/path/classloader-lifecycle suggestions do not demonstrate a current main-path correctness failure under the trusted server configuration model.

The current Build check is still queued, so the technical verdict is source-clear / waiting CI rather than fully clear. Daniel's repository permission is read-only, so this COMMENTED review records the technical conclusion only; a write-capable maintainer may still need to complete the approval gate after CI passes.

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI follow-up on the unchanged head: the Build that was queued during my last review has now completed with failures. The source-side verdict is still clear; the failing signal is not in this PR's storage-specific Zeta jar path.

The first hard failure is Run / Dependency licenses during its Maven install, followed by the JDK 11 unit-test and connector integration lanes failing on the same broad JDBC compilation errors (for example a duplicate AbstractJdbcRowConverter.setNullToStatementByDataType(...) and many missing generated methods/log fields): https://github.com/corgy-w/seatunnel/actions/runs/29675022325/job/88160977200. Those files are outside this PR's 15-file diff.

I also checked the four commits now ahead on dev; they are docs/E2E-only changes and do not contain a fix for this JDBC compilation failure. Therefore, simply syncing the latest dev is not currently evidenced to solve it, and I would avoid adding unrelated JDBC changes to this PR. Please rerun the failed workflow first to rule out a transient build/tooling issue. If the same clean-run compile failure reproduces, it should be handled as a baseline/CI issue rather than patched in this branch.

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basic information

  • PR title: [Improve][Zeta] Load storage-specific starter jars
  • Author: corgy-w
  • Link: #10618
  • Base branch: dev
  • State: OPEN
  • Change size: +613 / -73, 15 file(s)
  • Human review ready: No
  • Review time: 2026-07-26T17:03:00Z
  • Local branch: seatunnel-review-10618
  • Local worktree: shared bare PR 10618 review store

Stable review keys

  • pr_number: 10618
  • base_sha: ac7a5d9433230c58f72ec7e58240e06fec44069e
  • reviewed_base_sha: ac7a5d9433230c58f72ec7e58240e06fec44069e
  • merge_base_sha: ac7a5d9433230c58f72ec7e58240e06fec44069e
  • head_sha: 037668b66893dac95f514d9593245f4709705f91
  • reviewed_head_sha: 037668b66893dac95f514d9593245f4709705f91
  • technical_verdict: blocking
  • github_review_event: NOT_POSTED
  • human_review_ready: false
  • intended_change_correctness: blocking
  • diff_integrity: pass
  • deletion_total: 73
  • deletion_classified: 73
  • deletion_unclassified: 0
  • other_total: 6
  • other_confirmed: 2
  • other_resolved_in_current_head: 0
  • other_rejected_with_same_proposition_evidence: 3
  • other_not_applicable_with_reason: 1
  • other_unresolved: 0
  • merge_conclusion: fix_then_merge
  • reviewed_at: 2026-07-26T17:03:00Z

CI, compare, and merge-gate facts

  • mergeStateStatus: BLOCKED
  • reviewDecision: REVIEW_REQUIRED
  • mergeable_state: blocked
  • mergeable: True
  • rebaseable: False
  • required_ci_gate: failing
  • approval_gate: pending
  • conflict_gate: satisfied
  • merge_queue_gate: pending
  • compare: status=diverged, ahead_by=5, behind_by=52, total_commits=5, url=dev...037668b
  • Gate assessment: The technical verdict is kept separate from source, diff, deletion, other-finding, CI, conflict, and approval facts documented in the corresponding sections.

What problem this PR solves

  • User pain: Checkpoint/IMAP storage backends need starter-specific JARs, while global loading creates dependency conflicts.
  • Fix approach: Package storage starter directories, resolve an isolated classloader from configuration for SPI discovery, and retain root legacy-JAR fallback.
  • One-line summary: Storage isolation is directionally sound, but the config-derived plugin directory can currently escape starter/zeta.
  • Before: All storage JARs lived in global lib where OSS/Netty and other dependencies could conflict.
  • After: Each storage type isolated-loads from starter/zeta/{type}; an unvalidated type can point outside the root.

1. Code-change review

1.1 Core logic and real call/execution chain

  • Behavior before: All storage JARs lived in global lib where OSS/Netty and other dependencies could conflict.
  • Behavior after: Each storage type isolated-loads from starter/zeta/{type}; an unvalidated type can point outside the root.
  • Normal-path hit: conditional — Zeta checkpoint/IMAP config → FileUtils storage directory → isolated URLClassLoader/context → storage SPI factory → persistence.

Changed files, classes, and methods

  • seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/CheckpointService.java:60-95 CheckpointService storage loader — Checkpoint config resolves storage type, calls FileUtils for JAR URLs, and creates an isolated SPI loader.
  • seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:75-140 searchJarFilesForStorage — The utility composes the starter/zeta storage path, recursively finds JARs, and falls back to legacy root when split layout is absent.
  • seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/persistence/FileMapStore.java:55-120 FileMapStore.init — IMAP properties use the same resolver/loader to discover IMapStorage SPI.

Effective prerequisites

  • Effective when the storage type has a matching starter directory or legacy-root JARs.

Conditions where the change does not apply

  • Missing type uses legacy layout; malformed type can currently escape and is blocking.

Complete execution chain

1. seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/CheckpointService.java:60-95 -> CheckpointService storage loader [lifecycle]
   Checkpoint config resolves storage type, calls FileUtils for JAR URLs, and creates an isolated SPI loader.
   Side effect: Checkpoint config resolves storage type, calls FileUtils for JAR URLs, and creates an isolated SPI loader.
2. seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:75-140 -> searchJarFilesForStorage [method_call]
   The utility composes the starter/zeta storage path, recursively finds JARs, and falls back to legacy root when split layout is absent.
   Side effect: The utility composes the starter/zeta storage path, recursively finds JARs, and falls back to legacy root when split layout is absent.
3. seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/persistence/FileMapStore.java:55-120 -> FileMapStore.init [lifecycle]
   IMAP properties use the same resolver/loader to discover IMapStorage SPI.
   Side effect: IMAP properties use the same resolver/loader to discover IMapStorage SPI.
  • Recovery, exception, async, serialization, and concurrency paths: Loaders share the master/map lifecycle and checkpoint/FileMapStore persistence runs through isolated SPI instances.

Multi-table Sink Writer contract audit

  • Applicable: false
  • Sink implements SupportMultiTableSink: Not reported by GitHub
  • createWriter returns the required subclass: Not reported by GitHub
  • optionRule contains the replica option: Not reported by GitHub
  • Evidence: Not applicable because this PR adds no SupportMultiTableSinkWriter implementation.

1.2 Compatibility impact

  • Classification: fully_compatible (fully compatible)
  • API: The new split layout preserves legacy-root fallback and option names/default semantics are unchanged.
  • SPI: The new split layout preserves legacy-root fallback and option names/default semantics are unchanged.
  • Configuration: The new split layout preserves legacy-root fallback and option names/default semantics are unchanged.
  • Defaults: The new split layout preserves legacy-root fallback and option names/default semantics are unchanged.
  • Protocol and serialization: The new split layout preserves legacy-root fallback and option names/default semantics are unchanged.
  • Checkpoint/restore: The new split layout preserves legacy-root fallback and option names/default semantics are unchanged.
  • Historical behavior: The new split layout preserves legacy-root fallback and option names/default semantics are unchanged.
  • Migration guidance: No migration is needed for a fully compatible conclusion; otherwise follow the precise formal finding.
  • Incompatible-changes documentation: Compatibility was checked against the current diff; any required migration documentation is represented as a formal blocker.

1.3 Performance and side effects

  • CPU: Filesystem scanning and classloading occur only at startup/init, outside the record hot path.
  • Memory: Filesystem scanning and classloading occur only at startup/init, outside the record hot path.
  • GC: Filesystem scanning and classloading occur only at startup/init, outside the record hot path.
  • Network: Filesystem scanning and classloading occur only at startup/init, outside the record hot path.
  • Lock contention: Filesystem scanning and classloading occur only at startup/init, outside the record hot path.
  • Concurrency safety: Filesystem scanning and classloading occur only at startup/init, outside the record hot path.
  • Retry: Filesystem scanning and classloading occur only at startup/init, outside the record hot path.
  • Idempotency: Filesystem scanning and classloading occur only at startup/init, outside the record hot path.
  • Resource release: Filesystem scanning and classloading occur only at startup/init, outside the record hot path.
  • Overall: Filesystem scanning and classloading occur only at startup/init, outside the record hot path.

1.4 Error handling and logging

  • Exception propagation: Missing/null paths retain context, but containment does not fail closed; loader lifetime is not an unbounded leak.
  • Context: Missing/null paths retain context, but containment does not fail closed; loader lifetime is not an unbounded leak.
  • Log levels: Missing/null paths retain context, but containment does not fail closed; loader lifetime is not an unbounded leak.
  • Sensitive information: Missing/null paths retain context, but containment does not fail closed; loader lifetime is not an unbounded leak.
  • Overall: Missing/null paths retain context, but containment does not fail closed; loader lifetime is not an unbounded leak.

1.5 Diff integrity, deletion ledger, and scope audit

  • intended_change_correctness: blocking
  • diff_integrity: pass
  • deletion_ledger: total=73, classified=73, unclassified=0
  • Reconciliation: 73 = 73 + 0

Deletion, rename, and disappeared-capability ledger

  • deletion-001..deletion-016 | count=16 | deletion | intended_change | docs/en/engines/zeta/hybrid-cluster-deployment.md (old line 348 .. old line 392) — All 73 deleted lines are paired replacements in legacy docs layout, FileUtils/classloader, and checkpoint/FileMapStore loading paths.
  • deletion-017..deletion-032 | count=16 | deletion | intended_change | docs/en/engines/zeta/separated-cluster-deployment.md (old line 309 .. old line 352) — All 73 deleted lines are paired replacements in legacy docs layout, FileUtils/classloader, and checkpoint/FileMapStore loading paths.
  • deletion-033..deletion-042 | count=10 | deletion | intended_change | docs/zh/engines/zeta/hybrid-cluster-deployment.md (old line 344 .. old line 353) — All 73 deleted lines are paired replacements in legacy docs layout, FileUtils/classloader, and checkpoint/FileMapStore loading paths.
  • deletion-043..deletion-052 | count=10 | deletion | intended_change | docs/zh/engines/zeta/separated-cluster-deployment.md (old line 314 .. old line 323) — All 73 deleted lines are paired replacements in legacy docs layout, FileUtils/classloader, and checkpoint/FileMapStore loading paths.
  • deletion-053 | count=1 | deletion | intended_change | seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java (old line 52) — All 73 deleted lines are paired replacements in legacy docs layout, FileUtils/classloader, and checkpoint/FileMapStore loading paths.
  • deletion-054..deletion-059 | count=6 | deletion | intended_change | seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/CheckpointService.java (old line 54 .. old line 59) — All 73 deleted lines are paired replacements in legacy docs layout, FileUtils/classloader, and checkpoint/FileMapStore loading paths.
  • deletion-060..deletion-073 | count=14 | deletion | intended_change | seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/persistence/FileMapStore.java (old line 58 .. old line 71) — All 73 deleted lines are paired replacements in legacy docs layout, FileUtils/classloader, and checkpoint/FileMapStore loading paths.

Scope and base-drift items

  • No out-of-scope hunk, stale-base change, or merge artifact requires a separate ledger entry.

  • Out-of-scope hunk conclusion: All 15 files belong to storage packaging/loading/tests/bilingual docs.

  • Stale-base conclusion: No unrelated hunk, file deletion, or rollback exists; containment is an in-scope design blocker.

  • Merge-artifact conclusion: GitHub reports no conflict and the diff has no artifact.

2. Code-quality assessment

2.1 Code conventions, title format, and comments

  • Title format: The public utility has complete JavaDoc; @since/WARN requests do not follow repository convention.
  • Code conventions: The public utility has complete JavaDoc; @since/WARN requests do not follow repository convention.
  • Comment completeness: The public utility has complete JavaDoc; @since/WARN requests do not follow repository convention.

2.2 Test coverage and stability

  • Unit tests: covered — Tests cover isolated discovery, case/trim, and split/legacy/mixed layouts, but miss containment/traversal/symlink cases.
  • Component tests: covered — Tests cover isolated discovery, case/trim, and split/legacy/mixed layouts, but miss containment/traversal/symlink cases.
  • Engine integration tests: covered — Tests cover isolated discovery, case/trim, and split/legacy/mixed layouts, but miss containment/traversal/symlink cases.
  • E2E: missing — Tests cover isolated discovery, case/trim, and split/legacy/mixed layouts, but miss containment/traversal/symlink cases.
  • Regression tests: missing — Tests cover isolated discovery, case/trim, and split/legacy/mixed layouts, but miss containment/traversal/symlink cases.
  • Stability classification: risk

Test-stability evidence

  • seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/persistence/FileMapStore.java:55-120
    • Trigger: Existing tests are deterministic; untested malformed paths leave the security boundary without a regression signal.
    • Probability basis: Existing tests are deterministic; untested malformed paths leave the security boundary without a regression signal.
    • Analysis: Existing tests are deterministic; untested malformed paths leave the security boundary without a regression signal.

Missing scenarios

  • The blocking fix must add traversal/absolute/symlink containment tests; other null/partial coverage can join the same batch.

2.3 Documentation

  • User-visible change: true
  • docs/en: English/Chinese checkpoint and deployment docs align on split/legacy layout; the storage.type identifier/containment constraint should be documented.
  • docs/zh: English/Chinese checkpoint and deployment docs align on split/legacy layout; the storage.type identifier/containment constraint should be documented.
  • Examples: English/Chinese checkpoint and deployment docs align on split/legacy layout; the storage.type identifier/containment constraint should be documented.
  • Configuration truth: English/Chinese checkpoint and deployment docs align on split/legacy layout; the storage.type identifier/containment constraint should be documented.
  • URL truth: English/Chinese checkpoint and deployment docs align on split/legacy layout; the storage.type identifier/containment constraint should be documented.

2.4 Local-validation boundary and GitHub CI evidence

  • Local boundary: This round used complete static source, diff, call-chain, discussion, CI, and merge-gate evidence only; no local compilation, UT, IT, E2E, packaging, Docker, service startup, or real job was executed.

Local execution boundary

  • compilation: not_executed — Not executed; current-head GitHub CI is the runtime evidence.
  • unit_tests: not_executed — Not executed.
  • integration_tests: not_executed — Not executed.
  • e2e: not_executed — Not executed.
  • packaging: not_executed — Not executed.
  • docker: not_executed — Not executed.
  • service_start: not_executed — Not executed.
  • real_job: not_executed — Not executed.

Actually executed review commands

  • git diff --stat ac7a5d9433230c58f72ec7e58240e06fec44069e...037668b66893dac95f514d9593245f4709705f91
    • Result: passed
    • Explanation: Confirmed 15 files and +613/-73.
  • git diff --name-status ac7a5d9433230c58f72ec7e58240e06fec44069e...037668b66893dac95f514d9593245f4709705f91
    • Result: passed
    • Explanation: Completed the file-scope and deletion/rename audit.
  • git diff --unified=0 ac7a5d9433230c58f72ec7e58240e06fec44069e...037668b66893dac95f514d9593245f4709705f91
    • Result: passed
    • Explanation: Completed the current-head hunk-by-hunk review.
  • git diff --check
    • Result: passed
    • Explanation: The static whitespace check passed.

Required checks

Complete status-check rollup

3. Architecture assessment

3.1 Solution type: precise fix / workaround / long-term design

  • Type: long_term_design
  • Assessment: Isolated starter classloaders plus legacy fallback are a long-term design provided the plugin root fails closed.

3.2 Maintainability

Isolated starter classloaders plus legacy fallback are a long-term design provided the plugin root fails closed.

3.3 Extensibility

Isolated starter classloaders plus legacy fallback are a long-term design provided the plugin root fails closed.

3.4 Historical-version compatibility

Isolated starter classloaders plus legacy fallback are a long-term design provided the plugin root fails closed.

4. Disposition ledger for findings from other reviewers

  • total=6, confirmed=2, resolved_in_current_head=0
  • rejected_with_same_proposition_evidence=3, not_applicable_with_reason=1, unresolved=0
  • Reconciliation: 6 = 2 + 0 + 3 + 1 + 0

issuecomment-4083439262-null-config — DanielCarter-stack

  • Original proposition: Chained checkpoint-storage config access has an NPE risk.
  • Location: seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/CheckpointService.java:73-89
  • Thread: #10618 (comment)
  • Current-head evidence: CheckpointConfig.storage and storagePluginConfig are initialized by non-null defaults and missing type enters legacy fallback.
  • Disposition: rejected_with_same_proposition_evidence
  • Daniel disposition: Rejected with same-proposition lifecycle/config evidence.

issuecomment-4083439262-loader-close — DanielCarter-stack

  • Original proposition: URLClassLoaders leak because they are not explicitly closed.
  • Location: seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/CheckpointService.java:72-90; seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/persistence/FileMapStore.java:77-115
  • Thread: #10618 (comment)
  • Current-head evidence: Loaders live for the master-server or map-storage lifecycle, not per record/retry; immediate close can break lazy class/resource loading.
  • Disposition: rejected_with_same_proposition_evidence
  • Daniel disposition: Rejected with same-proposition lifecycle/config evidence.

issuecomment-4083439262-traversal — DanielCarter-stack

  • Original proposition: Unvalidated storage.type permits ../ traversal outside starter/zeta and dynamic JAR loading.
  • Location: seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:109-131
  • Thread: #10618 (comment)
  • Current-head evidence: The value is only trimmed/lowercased before resolve, with no normalized containment or allowlist, followed by recursive FOLLOW_LINKS walking.
  • Disposition: confirmed
  • Daniel disposition: Daniel +1; confirmed and aggregated as Issue 1.
  • Aggregated finding: 问题 1

issuecomment-4083439262-tests — DanielCarter-stack

  • Original proposition: Tests omit null/empty/nonexistent/traversal/invalid/symlink boundaries.
  • Location: seatunnel-common/src/test/java/org/apache/seatunnel/common/utils/FileUtilsTest.java
  • Thread: #10618 (comment)
  • Current-head evidence: Current tests cover case/trim/split/legacy/mixed layouts but not traversal, invalid identifiers, or containment/symlink proof.
  • Disposition: confirmed
  • Daniel disposition: Daniel +1; confirmed and aggregated as Issue 2.
  • Aggregated finding: 问题 2

issuecomment-4083439262-since — DanielCarter-stack

  • Original proposition: The new public utility needs an @SInCE tag.
  • Location: seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:75-90
  • Thread: #10618 (comment)
  • Current-head evidence: Repository FileUtils public utilities have no per-method @SInCE convention and this method already has complete JavaDoc.
  • Disposition: not_applicable_with_reason
  • Daniel disposition: Repository convention does not require this item.

issuecomment-4083439262-warn — DanielCarter-stack

  • Original proposition: Legacy-layout fallback should log WARN rather than INFO.
  • Location: seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:127-131
  • Thread: #10618 (comment)
  • Current-head evidence: Fallback is a documented backward-compatible supported path rather than a misconfiguration.
  • Disposition: rejected_with_same_proposition_evidence
  • Daniel disposition: Rejected with same-proposition lifecycle/config evidence.

5. Formal findings

问题 1 — storage.type can escape starter/zeta during plugin discovery

  • Source reviewer: DanielCarter-stack
  • Location: seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:109-131
  • Thread: #10618 (comment)
  • Problem and real execution path: searchJarFilesForStorage directly resolves config-derived storage.type and walks with FOLLOW_LINKS without separator/absolute-path rejection or normalized containment. searchJarFilesForStorage directly resolves config-derived storage.type and walks with FOLLOW_LINKS without separator/absolute-path rejection or normalized containment.
  • Current-head evidence: searchJarFilesForStorage directly resolves config-derived storage.type and walks with FOLLOW_LINKS without separator/absolute-path rejection or normalized containment.
  • Trigger condition: storage.type is ../other-dir, an absolute path, or a symlink resolving to a JAR directory outside the root.
  • Potential impact: The engine plugin loader scans and loads JARs outside the intended starter subtree, making startup depend on unrelated filesystem content and crossing the isolation boundary.
  • Best actionable fix: Allow only one supported identifier for storage.type; compare normalized absolute resolved.startsWith(root), and reject escaping symlinks, absolute paths, and separators.
  • Severity: high
  • Merge gate: blocking
  • Current-head disposition: confirmed_in_current_head
  • Already raised by another reviewer: true
  • Other finding ID: issuecomment-4083439262-traversal

问题 2 — Plugin-path containment lacks a focused regression matrix

  • Source reviewer: DanielCarter-stack
  • Location: seatunnel-common/src/test/java/org/apache/seatunnel/common/utils/FileUtilsTest.java:155-217
  • Thread: #10618 (comment)
  • Problem and real execution path: The current test matrix does not cover invalid identifiers, traversal, absolute paths, or symlink escape. The current test matrix does not cover invalid identifiers, traversal, absolute paths, or symlink escape.
  • Current-head evidence: The current test matrix does not cover invalid identifiers, traversal, absolute paths, or symlink escape.
  • Trigger condition: A future path-resolution change or malformed engine configuration.
  • Potential impact: The plugin-loading boundary can regress without a test signal.
  • Best actionable fix: Use temporary directories to cover null/blank/nonexistent, separator/absolute/traversal, normalized containment, and escaping symlinks.
  • Severity: low
  • Merge gate: non_blocking
  • Current-head disposition: confirmed_in_current_head
  • Already raised by another reviewer: true
  • Other finding ID: issuecomment-4083439262-tests

6. Findings summary

ID Finding Location Severity Merge gate
问题 1 storage.type can escape starter/zeta during plugin discovery seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:109-131 high blocking
问题 2 Plugin-path containment lacks a focused regression matrix seatunnel-common/src/test/java/org/apache/seatunnel/common/utils/FileUtilsTest.java:155-217 low non_blocking

7. Merge conclusion

Conclusion:can merge after fixes

Blocking items

  • storage-path-containment [source] (问题 1): The config-derived plugin path can escape starter/zeta.

Non-blocking recommendations

  • 问题 2: Use temporary directories to cover null/blank/nonexistent, separator/absolute/traversal, normalized containment, and escaping symlinks.

Overall assessment

Isolated starter classloaders plus legacy fallback are a long-term design provided the plugin root fails closed.

Better alternative implementation and trade-offs

  • Alternative: Global lib is simpler but preserves dependency conflicts; a validated contained starter path is the correct trade-off.
  • Trade-offs: Global lib is simpler but preserves dependency conflicts; a validated contained starter path is the correct trade-off.

8. GitHub publication and reply readback

  • Publication event: COMMENT
  • Publisher identity: DanielLeens (repository permission READ)
  • Reviewed commit: 037668b66893dac95f514d9593245f4709705f91
  • This complete report is the submitted GitHub Review body. Its immutable review ID, URL, state, and submission time are verified from the GitHub API immediately after creation and retained in the local bilingual evidence.
  • Any precise line-thread replies are separate GitHub objects and are likewise verified individually.

Closes the blocking finding from review: storage.type is user
configuration, and searchJarFilesForStorage resolved it directly
against the starter/zeta directory, so a path-shaped value
("../other-dir", an absolute path) or a subdirectory symlinked outside
the root made the engine plugin loader scan and load JARs from
unrelated filesystem locations, crossing the starter isolation
boundary.

- storage.type must now match [a-z0-9_-]+ after trim/lowercase; every
  legitimate value (hdfs, s3, oss, ...) passes unchanged, and anything
  path-shaped fails closed to the legacy whole-root scan, which never
  leaves zetaDirectory. The rejection is logged with the offending
  value.
- Both the common/ and the storage-specific subdirectory are only
  scanned when their real path (symlinks resolved) is still inside the
  root's real path, because the JAR walk follows links; escaping
  directories are skipped with a warning naming the resolved target.
- Added the regression matrix the review asked for: traversal value,
  absolute-path value, and an escaping-symlink subdirectory (POSIX
  only) all assert the escaped JAR is never loaded while in-root
  loading keeps working.

Behavior for every valid configuration is unchanged: same directories
scanned, same fallback to the legacy layout when no split directory
exists.
Four deployment-doc conflicts: dev enriched the legacy lib/-layout
notices with the new seatunnel-shade jar names and explanations while
this branch rewrote the same notices for the split starter/zeta
layout. Resolved by keeping this branch's layout statement (jars ship
in starter/zeta/common plus the storage-specific directory) and
folding in dev's current shaded-jar naming, explanation, and jar
lists -- this branch's old text referenced the pre-rename jar names,
which would have been stale documentation.
@davidzollo

Copy link
Copy Markdown
Contributor

Closed out the blocking finding from the 2026-07-26 review, took the non-blocking test suggestion with it, and synced the branch with current dev:

The containment fix (FileUtils.searchJarFilesForStorage): storage.type is user configuration, and it was resolved directly against the starter/zeta root — so "../other-dir", an absolute path, or a subdirectory symlinked outside the root would make the engine plugin loader scan and load JARs from unrelated filesystem locations. Now:

  • the value must match [a-z0-9_-]+ after trim/lowercase — every legitimate identifier (hdfs, s3, oss, …) passes unchanged; anything path-shaped fails closed to the legacy whole-root scan (which never leaves zetaDirectory), with the offending value logged;
  • both common/ and the storage-specific directory are scanned only when their real path (symlinks resolved) is still inside the root's real path, since the JAR walk follows links; escaping directories are skipped with a warning naming the resolved target.

Behavior for every valid configuration is unchanged: same directories scanned, same legacy fallback when no split layout exists.

Regression matrix added (the review's non-blocking ask): traversal value, absolute-path value, and an escaping-symlink subdirectory (POSIX-only — symlink creation needs privileges on Windows runners) all assert the escaped JAR is never loaded while in-root loading keeps working.

Dev sync: four deployment-doc conflicts — dev had enriched the legacy lib/-layout notices with the renamed seatunnel-shade-* jar names while this branch rewrote the same notices for the split layout. Kept this branch's layout statement and folded in dev's current jar naming/lists, since this branch's old text referenced the pre-rename jar names and would have shipped stale documentation.

Fresh CI is running on the new head.

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What Problem Does This PR Solve?

Zeta's checkpoint storage and IMAP persistence backends (S3, OSS, etc.) each pull in their own
Hadoop/SDK dependencies. Before this PR, those jars had to live in the global lib/ classpath,
where OSS's Aliyun SDK stack (and its Netty version) could collide with other storage
implementations' dependencies loaded into the same classloader. The fix packages storage-specific
jars under starter/zeta/{common,s3,oss} and has CheckpointService / FileMapStore build an
isolated URLClassLoader scoped to the configured storage.type before doing SPI discovery,
falling back to the legacy whole-directory scan when the split layout isn't present. One-sentence
summary: storage dependency isolation for Zeta's checkpoint/IMAP storage backends, with full
backward compatibility for the flat starter/zeta layout.

This is a NEED_REREVIEW. Daniel's last review (2026-07-26, head 037668b66893) confirmed one
HIGH-severity finding raised by another reviewer (DanielCarter-stack): storage.type was
resolved directly against the starter/zeta root with no containment check, so a path-shaped value
(../other-dir, an absolute path, or an escaping symlink) could make the engine plugin loader
scan and load JARs from outside the intended subtree. The head has since moved to 77afe1b29dee
(today, davidzollo's "dev sync + containment fix" commit), so this is a full fresh re-review of
the entire current diff, not just the incremental change.

1. Code Change Review

1.1 Core Logic Analysis

Before (as of the July 26 review): FileUtils.searchJarFilesForStorage resolved
zetaDirectory.resolve(normalizedStorageType) with only trim()/toLowerCase() applied, then
walked it with FOLLOW_LINKS. "../other-dir", an absolute path, or a subdirectory that was a
symlink to somewhere outside starter/zeta would all be scanned and their JARs loaded into the
engine.

After (current head, seatunnel-common/.../FileUtils.java:36-137):

private static final Pattern STORAGE_TYPE_PATTERN = Pattern.compile("[a-z0-9_-]+");

private static boolean isContainedDirectory(Path directory, Path rootRealPath) throws IOException {
    if (!Files.isDirectory(directory)) return false;
    Path realPath = directory.toRealPath();
    if (!realPath.startsWith(rootRealPath)) {
        log.warn("Ignoring storage jar directory {} because it resolves to {} outside {}", ...);
        return false;
    }
    return true;
}

public static List<URL> searchJarFilesForStorage(@NonNull Path zetaDirectory, String storageType) {
    ...
    if (!STORAGE_TYPE_PATTERN.matcher(normalizedStorageType).matches()) {
        log.warn("Ignoring illegal storage type '{}' ...: only [a-z0-9_-] names are allowed. "
                + "Falling back to scanning {}", storageType, zetaDirectory);
        return searchJarFiles(zetaDirectory);
    }
    Path zetaRealPath = zetaDirectory.toRealPath();
    Path commonDir = zetaDirectory.resolve("common");
    if (isContainedDirectory(commonDir, zetaRealPath)) { ... jars.addAll(searchJarFiles(commonDir)); }
    Path storageDir = zetaDirectory.resolve(normalizedStorageType);
    if (isContainedDirectory(storageDir, zetaRealPath)) { ... jars.addAll(searchJarFiles(storageDir)); }
    ...
}

Key findings on the current head:

  • storage.type is now validated against [a-z0-9_-]+ (whole-string match) before it is ever
    used to build a path — any separator, .., drive/scheme prefix, or absolute-path shape fails
    the regex and falls back to the legacy whole-directory scan, which never leaves zetaDirectory.
  • Even a value that passes the regex is still subject to isContainedDirectory, which resolves
    the real path (symlinks included, since the JAR walk uses FOLLOW_LINKS) and requires
    realPath.startsWith(rootRealPath). This closes the symlink-escape vector specifically, not
    just the string-shaped traversal vector.
  • I re-derived the exploit scenario from the July 26 finding by hand: storage.type = "../etc"
    now fails the regex (contains / and .) → legacy scan of zetaDirectory only. An absolute
    path as storage.type also fails the regex (contains /). A symlink named s3 under
    starter/zeta pointing outside the root passes the regex (it's s3) but fails
    isContainedDirectory's startsWith check → skipped with a WARN log naming the resolved
    target. All three vectors from the confirmed finding are closed by independent, overlapping
    checks (regex first, containment second), which is a reasonable defense-in-depth structure
    rather than relying on a single guard.
  • I confirmed this isn't just theoretical: the CI run for the current head (see 2.2) executed the
    updated FileUtilsTest — including the new traversal, absolute-path, and symlink-escape
    regression tests — and all 10 test cases in that class passed on ubuntu-latest/JDK 8.

Complete runtime path (retraced from SeaTunnelServer on the current head, not assumed from
the prior review):

1. seatunnel-engine-server/.../SeaTunnelServer.java:196-209 -> startMaster() [lifecycle, master-only, called once per process]
   Invoked once from init(), either directly (MASTER role) or as part of the MASTER_AND_WORKER
   branch. Not part of any retry loop; this is a one-shot startup step.
2. seatunnel-engine-server/.../CheckpointService.java:171-207 -> CheckpointService(config) [constructor]
   Delegates to CheckpointService(config, Common.appStarterDir().resolve("zeta")).
   Reads config.getStorage().getStoragePluginConfig().get("storage.type") (see 1.3 for null-safety).
3. seatunnel-common/.../FileUtils.java:80-137 -> searchJarFilesForStorage(zetaDirectory, storageType)
   Validates storageType, resolves common/ + <type>/ under containment, falls back to legacy scan.
4. seatunnel-engine-server/.../CheckpointService.java:188-206 -> URLClassLoader + TemporaryClassLoaderContext
   If storageJars is non-empty, wraps the current context classloader; otherwise keeps it unchanged.
   FactoryUtil.discoverFactory(...) runs the SPI lookup with the context classloader temporarily
   swapped, then TemporaryClassLoaderContext.close() restores the original context classloader on
   the same thread (seatunnel-common/.../TemporaryClassLoaderContext.java:31-52, unchanged by this
   PR — this is the engine's existing, pre-existing swap-and-restore utility).
5. Parallel path: Hazelcast IMap persistence -> FileMapStoreFactory.newMapStore() [seatunnel-engine-server/.../FileMapStoreFactory.java:29]
   -> new FileMapStore() -> FileMapStore.init(instance, properties, mapName) [seatunnel-engine-server/.../FileMapStore.java:54-56]
   -> init(..., Common.appStarterDir().resolve("zeta")) [FileMapStore.java:60-110] follows the same
   searchJarFilesForStorage -> optional URLClassLoader -> TemporaryClassLoaderContext -> FactoryUtil.discoverFactory
   sequence, once per persisted IMap name at master startup.
6. Later: CheckpointService.getLatestCheckpoint() / FileMapStore.store()/load() use the already-
   constructed checkpointStorage / mapStorage instances — no further classloading occurs on the
   record hot path.

Both entry points (new CheckpointService(...) and FileMapStoreFactory.newMapStore()) are
called exactly once per process lifetime at master startup — I grepped the whole pr-10618 tree
for both call sites and found no other callers besides the two @VisibleForTesting test
constructors. This confirms the "startup/init only, outside the record hot path" characterization
from the prior review still holds on the current diff.

1.2 Compatibility Impact

Fully compatible.

  • Legacy flat-starter/zeta installs: searchJarFilesForStorage falls back to
    searchJarFiles(zetaDirectory) (unchanged, recursive, unbounded-depth) whenever the split
    common/+<type>/ layout isn't detected — same behavior as before this PR existed.
  • Mixed layout (split dirs present but with legacy jars still at zeta root): root-level jars
    (searchJarFiles(zetaDirectory, 1), depth-limited so it doesn't re-walk common//<type>/)
    are still added, so an in-place upgrade that hasn't fully adopted the split layout keeps
    working — verified by testSearchJarFilesForStorageKeepsLegacyRootJarsInMixedLayout.
  • Assembly changes (seatunnel-dist/src/main/assembly/assembly-seatunnel-bin{,-ci}.xml) are
    purely additive: the existing /lib dependencySets for seatunnel-shade-hadoop3-uber and
    seatunnel-shade-hadoop-aws are untouched; three new dependencySets add jars under
    /starter/zeta/{common,s3,oss} without removing anything from /lib.
  • seatunnel-dist/pom.xml only adds new provided-scope dependencies (hadoop-aliyun,
    aliyun-sdk-oss, jdom, netty-buffer) — no version bumps or removals of existing
    dependencies.
  • Config/option semantics: no Option was added, renamed, or had its default changed;
    storage.type was already user-supplied plugin config consumed by FactoryUtil.discoverFactory.
  • Checkpoint/restore format: unaffected — this PR only changes how the CheckpointStorage/
    IMapStorage implementation class is located, not the serialized checkpoint/IMAP data format.

1.3 Performance / Side-Effect Analysis

  • CPU/IO: Files.walk over common/ + <type>/ (bounded to those two subtrees) plus a
    depth-1 scan of the root — all filesystem-bound, startup-only, not on the record hot path.
  • Classloader lifecycle: new CheckpointService(...) and each FileMapStore.init(...) run
    exactly once per process (see runtime path above), so there is no unbounded accumulation of
    URLClassLoader instances over the process lifetime. The URLClassLoader is never explicitly
    close()d, but since checkpointStorage/mapStorage hold instances of classes loaded by it for
    the entire life of the service, an early close() would not free anything the JVM could
    otherwise reclaim while those instances are in use — the earlier "MAJOR: URLClassLoader not
    closed" suggestion (from the initial DanielCarter-stack comment) does not apply to a
    singleton-at-startup lifecycle; it would matter if these constructors were invoked repeatedly
    (e.g., per record or per retry), which I confirmed via the call-site grep is not the case here.
  • TOCTOU note (non-blocking): there is a theoretical gap between isContainedDirectory's
    toRealPath()/startsWith() check and the later Files.walk in searchJarFiles, but exploiting
    it requires local filesystem write access to swap a symlink under starter/zeta between the two
    calls — an attacker with that capability could already drop a malicious JAR directly under
    starter/zeta/common without touching storage.type at all, so this doesn't cross a real
    trust boundary given the existing "trusted server configuration/filesystem" model the engine
    already assumes elsewhere (e.g., connector plugin loading).

1.4 Error Handling and Logging

  • Illegal storage.type (fails the [a-z0-9_-]+ regex) → log.warn naming the offending value
    and the fallback target. Escaping symlink → log.warn naming the resolved real path and the
    root. Benign fallback (no split layout present, e.g. a legacy install) → log.info. This
    differentiation is an improvement on the initial PR version and addresses the spirit of the
    original "log level" nitpick (illegal/anomalous input is now WARN; a supported legacy path is
    INFO).
  • FileMapStore.init's existing catch (RuntimeException e) around factory discovery/creation
    (with log.error including mapName and storageType) is preserved verbatim around the new
    classloader-wrapped call — no exception context was dropped by wrapping it in
    TemporaryClassLoaderContext.
  • CheckpointService's constructor is annotated @SneakyThrows (pre-existing pattern in this
    class, unchanged) — an IOException from searchJarFilesForStorage (e.g., permission-denied
    reading common/) at master startup will not be silently swallowed; it propagates and would
    fail cluster initialization, which is intentional fail-fast behavior for a storage the whole
    cluster's checkpoint mechanism depends on.

Issue 1: dev-baseline compile break makes the current head's own new engine-server tests
unverified by CI (currently red for an unrelated reason)

  • Location: seatunnel-engine/seatunnel-engine-server/src/test/java/org/apache/seatunnel/engine/server/event/JobStateEventTest.java:165
  • Problem: The fork CI run for the current head (77afe1b29dee) fails at
    maven-compiler-plugin:testCompile for module seatunnel-engine-server with cannot find symbol: variable FAILED_JOB_EVENT_TIMEOUT_SECONDS. I traced this to dev commit 033612bfd
    ("[Fix][E2E] Address follow-up review issues for CI stabilization (#11097)", authored by
    davidzollo, merged 2026-08-23 22:25, i.e. hours before this PR's fresh dev-sync this morning).
    That commit renamed JobStateEventTest's local FAILED_JOB_EVENT_TIMEOUT_SECONDS field to a
    static import of CheckpointErrorRestoreEndTest.RESTORE_TO_FAILED_TIMEOUT_SECONDS and updated
    one usage (line ~91) but missed a second usage at line 165, which still references the deleted
    field name. I confirmed git diff dev...pr-10618 for this file is empty (byte-identical to
    dev HEAD) and that this PR's merge-base with dev is dev HEAD (406c66789) — this is
    purely a dev-side bug this PR inherited via its own dev-sync commit this morning, not
    something introduced by PR #10618's 15-file diff.
  • Potential impact for this PR specifically: because the broken test class lives in the same
    Maven module (seatunnel-engine-server) as this PR's two new tests
    (CheckpointServiceStorageClassLoaderTest, FileMapStoreTest), the module fails to
    test-compile at all, so those new isolation tests have not actually executed in this CI run —
    I grepped the full CI log and found no CheckpointServiceStorageClassLoaderTest or
    FileMapStoreTest output anywhere. FileUtilsTest (in seatunnel-common, a different module)
    did compile and run, and all 10 of its cases — including the traversal/absolute/symlink
    regression tests — passed.
  • Best actionable fix: this is not something to patch inside PR #10618 (per the "don't add
    unrelated changes" guidance from Daniel's own July 19 comment on this same PR). It needs either
    a separate fix on dev (restore the local field, or fix the second usage to reference
    RESTORE_TO_FAILED_TIMEOUT_SECONDS) followed by a rebase of this branch, or simply waiting for
    dev to be fixed and re-syncing/rerunning CI. Once that lands, this PR's own new engine tests
    need to actually go green before merge.
  • Severity: Medium (blocks confirmation that this PR's own new tests pass, but is not a defect
    in this PR's diff).
  • Raised by another reviewer: No.

2. Code Quality Assessment

2.1 Coding Standards

  • FileUtils.searchJarFilesForStorage has complete Javadoc (@param, @return, @throws).
    isContainedDirectory and the STORAGE_TYPE_PATTERN constant both have explanatory Javadoc
    covering why (not just what) — consistent with the "explain why, not what" comment standard.
  • CheckpointService's package-private @VisibleForTesting constructor and FileMapStore's
    package-private @VisibleForTesting overload both have a one-line Javadoc explaining their
    test-only purpose.
  • No @since tag on the new public FileUtils.searchJarFilesForStorage method — I confirmed via
    git grep that no method in seatunnel-common/src/main/java/.../FileUtils.java (or elsewhere
    in seatunnel-common) carries an @since tag, so this is not a repository convention being
    skipped; the earlier ask for it does not apply here.
  • New test classes (CheckpointServiceStorageClassLoaderTest, FileMapStoreTest additions,
    FileUtilsTest additions) all have ASF license headers and class/method-level Javadoc
    explaining the regression being guarded against, not just restating the method name.

2.2 Test Coverage and Test Stability

  • Stability classification: Stable, with one caveat noted in Issue 1 above (this PR's two new
    engine-server tests haven't executed in the current CI run due to an unrelated module-wide
    compile break).
  • seatunnel-common/.../FileUtilsTest.java (seatunnel-common/src/test/.../FileUtilsTest.java:155-278):
    6 new tests cover common+storage-dir loading with mixed-case/whitespace input, legacy-layout
    fallback, mixed split/legacy layout, traversal rejection ("../outside"), absolute-path
    rejection, and symlink-escape rejection (@DisabledOnOs(OS.WINDOWS) with a documented reason —
    symlink creation needs elevated privileges on Windows CI runners). All 10 cases in this class
    ran and passed in the current CI run (ubuntu-latest, JDK 8) — direct evidence the containment
    fix works, not just static-analysis confidence.
  • CheckpointServiceStorageClassLoaderTest (new file,
    seatunnel-engine-server/src/test/.../CheckpointServiceStorageClassLoaderTest.java): compiles a
    throwaway CheckpointStorageFactory implementation into a real JAR at test time (with a
    META-INF/services provider entry) and places it only under the temp zeta/s3/ directory, then
    asserts CheckpointService's package-private constructor can discover and instantiate it. This
    is a genuine end-to-end proof that the isolated classloader path reaches SPI discovery
    correctly, not a mock-based approximation.
  • FileMapStoreTest gets the equivalent addition for IMapStorageFactory discovery via
    FileMapStore.init(...).
  • Missing/lower-priority (non-blocking): no test exercises the IOException path inside
    FileMapStore.init (e.g., a genuinely unreadable zetaDirectory), and there's no explicit test
    for an invalid identifier that embeds a separator mid-string (e.g., "s3/../etc") — though this
    is structurally the same code path as the pure-traversal test already present (both fail the
    same whole-string regex), so the marginal coverage value is low.

2.3 Documentation Updates

  • docs/en/engines/zeta/checkpoint-storage.md and its docs/zh counterpart both gained a new
    paragraph explaining the starter/zeta/common + starter/zeta/<type> split-loading behavior,
    the legacy-scan fallback, and that COS jars are still not bundled (must be added to lib/
    manually) — this last point is an accurate, useful caveat since the assembly changes in this PR
    only cover S3/OSS/common, not COS.
  • hybrid-cluster-deployment.md and separated-cluster-deployment.md (both languages) had their
    OSS/S3 "make sure the following jars are in the lib directory" notices updated to explain that
    the official binary package now copies these jars to starter/zeta/{common,oss} /
    starter/zeta/{common,s3} and that manual placement in lib/ is only needed for custom builds.
    I checked the EN and ZH wording side by side — they convey the same information (not a verbatim
    translation, but semantically aligned), consistent with the bilingual-docs requirement.
  • No incompatible-changes doc entry is needed since this change is fully backward compatible (see
    1.2).

3. Architectural Soundness

3.1 Elegance of the Solution: Precise fix

The regex allowlist ([a-z0-9_-]+) plus real-path containment check (isContainedDirectory) is a
standard, well-understood defense-in-depth pattern for user-supplied path segments, and it's
applied consistently to both the common/ and <type>/ resolution — not just the
storage.type-derived one. Falling back to the pre-existing legacy whole-root scan (rather than
throwing) on any rejection keeps the failure mode "less isolated than intended" instead of
"cluster fails to start," which is a reasonable choice for a fail-safe-open default in a startup
path, since the legacy scan itself never leaves zetaDirectory.

3.2 Maintainability

The two @VisibleForTesting constructor/method overloads that accept an explicit zetaDirectory
are a clean way to make CheckpointService and FileMapStore testable against a temp directory
without needing to fake Common.appStarterDir() globally — this is a good pattern other engine
tests could reuse.

3.3 Extensibility

Adding a new storage type only requires adding a new assembly dependencySet targeting
/starter/zeta/<type> — no code change is needed in FileUtils, CheckpointService, or
FileMapStore, since the directory name is derived directly from the storage.type config value.

3.4 Historical-Version Compatibility

Confirmed compatible for clusters upgrading in place from a version that only has the flat
starter/zeta layout (falls back to legacy scan) and for clusters mid-upgrade with a partially
split layout (mixed-layout test). No checkpoint/IMAP data format or Option contract changed.

4. Issue Summary

Number Issue Location Severity
Issue 1 dev-baseline compile break (unrelated to this PR) leaves this PR's own new engine-server tests unverified by the current CI run seatunnel-engine-server/.../event/JobStateEventTest.java:165 Medium

No High or Low severity issues remain open in this PR's own diff. The previously-confirmed HIGH
finding (storage.type path-traversal/symlink-escape) and the previously-confirmed test-coverage
gap are both resolved and verified passing in the current CI run.

5. Merge Recommendation

Conclusion: Ready to merge after fixes

  1. Blockers — must be fixed:

    • None in this PR's own diff. The only open item (Issue 1) is a dev-baseline break this PR
      inherited via this morning's dev-sync; it needs dev fixed (or this branch rebased past a
      fix) and a green CI run confirming CheckpointServiceStorageClassLoaderTest and
      FileMapStoreTest actually pass, since neither has executed successfully yet in any CI run
      I could find for this head.
  2. Recommended fixes — non-blocking:

    • Consider adding a test for FileMapStore.init's IOException path and/or an
      embedded-separator invalid identifier, though the marginal value is low given the existing
      regex-based coverage.

Overall assessment: This is a solid, backward-compatible improvement to Zeta's storage
dependency isolation. The HIGH-severity path-containment issue from the prior round has been
fixed correctly and thoroughly (regex allowlist + real-path containment, covering both the
string-traversal and symlink-escape vectors independently), and the fix is backed by passing
regression tests observed in the current CI run, not just static reasoning. The only remaining
gap is procedural, not architectural: get a clean CI run (after the unrelated dev-side
JobStateEventTest.java break is resolved) that actually exercises this PR's two new
engine-server tests before merging.

Alternative implementation note: none — the split-directory-plus-isolated-classloader design
is the right trade-off here; keeping everything in the global lib/ (the pre-PR state) is simpler
but is exactly the dependency-conflict problem this PR sets out to fix.

@SEZ9 SEZ9 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this. I reviewed the latest head 77afe1b29dee.

What this PR fixes

  • User pain: Zeta checkpoint/IMAP storage jars for S3 and OSS all live in lib/, so their Hadoop/SDK stacks are loaded into one classloader and collide with each other and with connector dependencies.
  • Fix approach: Package storage jars into starter/zeta/common plus per-storage subdirectories (s3, oss) in both dist assemblies, and add FileUtils.searchJarFilesForStorage that loads common/ plus the directory matching plugin-config.storage.type (with pattern validation, symlink containment via toRealPath, root-level legacy-jar pickup, and a whole-directory fallback for the legacy layout), with EN/ZH doc updates.
  • One-line summary: The split-layout loading, tests, and docs are in place, but the containment guard only checks the top-level directory (nested symlinks still escape via FOLLOW_LINKS), the empty/illegal storage.type fallbacks silently re-widen the scan to the whole tree (contradicting the "fail closed" comment and the docs' "always loads common" claim), a missing storage dir is silently ignored deferring failure to a runtime ClassNotFoundException, and unguarded toRealPath() calls can abort engine startup.

Runtime chain I rechecked

SeaTunnelServer startup (checkpoint / IMAP storage initialization)
  -> CheckpointService storage bootstrap reads plugin-config.storage.type and resolves the starter dir  CheckpointService.java:63
    -> Common.appStarterDir().resolve("zeta")
    -> FileUtils.searchJarFilesForStorage(zetaDirectory, storageType)  FileUtils.java:119
      -> null/empty storageType -> searchJarFiles(zetaDirectory) [legacy whole-tree scan]  FileUtils.java:128
      -> STORAGE_TYPE_PATTERN.matcher(normalizedStorageType) -> on mismatch, falls back to searchJarFiles(zetaDirectory)  FileUtils.java:135
      -> zetaDirectory.toRealPath() [can throw IOException on dangling symlink]  FileUtils.java:146
      -> isContainedDirectory(commonDir, zetaRealPath)  FileUtils.java:88
        -> Files.isDirectory / directory.toRealPath() / realPath.startsWith(rootRealPath)
      -> searchJarFiles(commonDir)  FileUtils.java:49
        -> Files.walk(directory, maxDepth, FileVisitOption.FOLLOW_LINKS) [follows nested symlinks past the containment check]  FileUtils.java:59
      -> isContainedDirectory(storageDir, zetaRealPath) -> searchJarFiles(storageDir)  FileUtils.java:157
      -> splitLayoutDetected -> searchJarFiles(zetaDirectory, 1) [root-level legacy jars]  FileUtils.java:164
    -> returned URLs added to the storage classloader used to instantiate the CheckpointStorage / IMAP persistence factory

Findings

Issue 1: Once the split layout is detected, jars in non-matching subdirectories of starter/zeta are silently dropped — an upgrade regression for users who nested custom storage jars (e.g. COS) under starter/zeta

  • Location: seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:163
  • Why it matters: - Root cause: when splitLayoutDetected is true, the method loads only common/, the directory matching the normalized storage type, and root-level jars at depth 1 (searchJarFiles(zetaDirectory, 1)). The pre-existing behavior was a full recursive scan of starter/zeta, so any other subdirectory (e.g. a user-created starter/zeta/cos/ when storage.type is cos but the packaged dirs are only common/s3/oss, or an arbitrary starter/zeta/extra-libs/ folder) that used to be picked up is now silently skipped.
  • Impact: since the official dist always ships common/, the split-layout branch is always taken after upgrade, and jars users nested under other subdirectories vanish from the storage classpath with no warning, surfacing later as ClassNotFoundException in the storage factory.
  • Evidence: seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:155-158 Path storageDir = zetaDirectory.resolve(normalizedStorageType); if (isContainedDirectory(storageDir, zetaRealPath)) { splitLayoutDetected = true; jars.addAll(searchJarFiles(storageDir));
  • Suggested fix: After upgrade the official dist always contains common/, so this branch is always taken — and it only sees common/, the matched storage dir, and root-level jars at depth 1. Any other subdirectory a user previously created under starter/zeta (previously picked up by the full recursive scan) is now silently skipped, surfacing later as ClassNotFoundException in the storage factory. Please log a WARN listing the skipped subdirectories here so operators can diagnose the layout change, and mention it in the release/upgrade notes.
  • Severity: Medium

*Issue 2: Symlink containment is only enforced at the top-level directory; the JAR walk still follows nested symlinks (and symlinked .jar files) out of the starter/zeta root, contradicting the isContainedDirectory guarantee

  • Location: seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:152
  • Why it matters: - Root cause: isContainedDirectory resolves only the top-level common/ or <storage-type>/ directory via toRealPath(), but the subsequent scan delegates to searchJarFiles(directory), which walks with Integer.MAX_VALUE depth and FileVisitOption.FOLLOW_LINKS (FileUtils.java:51, :59). A symlinked subdirectory inside common/ (e.g. common/deps -> /opt/attacker), or a symlinked file named evil.jar anywhere in the tree — including the depth-1 root scan at line 163 — resolves outside zetaRealPath and is still loaded.
  • Impact: jars outside the starter/zeta root end up in the engine classloader, which is exactly the escape the Javadoc at lines 84-87 claims this method prevents.
  • Evidence: seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:59 try (Stream<Path> paths = Files.walk(directory, maxDepth, FileVisitOption.FOLLOW_LINKS)) {; seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:152 jars.addAll(searchJarFiles(commonDir));; seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:163 jars.addAll(searchJarFiles(zetaDirectory, 1));
  • Suggested fix: isContainedDirectory only validates the top-level directory, but this call walks it with FOLLOW_LINKS at unlimited depth (see line 59). A nested symlink such as common/deps -> /opt/elsewhere, or a symlinked evil.jar file (including in the depth-1 root scan at line 163), still resolves outside zetaRealPath and gets loaded into the engine classloader — exactly the escape the javadoc at lines 84-87 says this method prevents. Please enforce containment per jar: inside the walk, resolve each candidate with path.toRealPath() and skip anything that doesn't startsWith(zetaRealPath) (or run the storage-layout walk without FOLLOW_LINKS).
  • Severity: Medium

Issue 3: An invalid storage.type silently widens the scan to the entire starter/zeta tree; the "fail closed" comment is inaccurate and misconfiguration reintroduces the exact classpath-conflict problem this PR fixes

  • Location: seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:142
  • Why it matters: - Root cause: when storage.type fails STORAGE_TYPE_PATTERN, the code logs a warning and returns searchJarFiles(zetaDirectory) (FileUtils.java:142), i.e. it loads jars for every storage backend (common + s3 + oss + root) into one classloader. The inline comment at line 135 calls this "Fail closed", but relative to the split layout it is the widest possible scan, not the narrowest.
  • Impact: an operator typo like storage.type: S3://bucket or a copy-paste with a slash silently degrades to the whole-tree scan, reintroducing the dependency conflicts this PR is meant to fix, with only a WARN as signal.
  • Evidence: seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:136 if (!STORAGE_TYPE_PATTERN.matcher(normalizedStorageType).matches()) {; seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:142 return searchJarFiles(zetaDirectory);
  • Suggested fix: Falling back to searchJarFiles(zetaDirectory) on an illegal storage.type is the widest scan, not "fail closed" as the comment above states: a typo like S3://bucket silently loads every backend's jars into one classloader and reintroduces the dependency conflicts this PR is meant to fix, with only a WARN as signal. I'd either throw a configuration exception here (the storage factory will reject the type anyway) or narrow the fallback to common/ + root-level jars, and fix the comment either way.
  • Severity: Medium

Issue 4: Fallback paths (empty or illegal storage.type) scan the whole zeta directory, loading conflicting storage stacks (s3 + oss) into one classloader and bypassing the symlink containment check

  • Location: seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:128
  • Why it matters: - Root cause: both the empty-type branch and the illegal-pattern branch call searchJarFiles(zetaDirectory), which recursively walks every subdirectory. In the official split layout that means common/, s3/, and oss/ jars are all merged into the same classloader.
  • Impact: this reintroduces exactly the dependency conflicts (e.g., OSS Aliyun SDK's Netty vs other stacks) that the split layout was created to avoid — and it happens for the default case where storage.type is not set at all. The full recursive scan also follows symlinks with no isContainedDirectory check, unlike the split-layout path.
  • Evidence: seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:142 return searchJarFiles(zetaDirectory);; docs/en/engines/zeta/checkpoint-storage.md If storage.typeis empty, SeaTunnel falls back to scanning the wholestarter/zeta directory.
  • Suggested fix: With the official split layout, an unset/empty storage.type takes this branch and recursively loads common/, s3/, and oss/ jars into the same classloader — reintroducing the exact dependency conflicts (e.g., OSS SDK Netty versions) this PR is meant to eliminate, for what is likely the default configuration. This full scan also follows symlinks with no isContainedDirectory check, unlike the split path below. When common/ exists, could we load only common/ + root-level jars here, and keep the whole-tree scan strictly for legacy layouts without a common/ directory?
  • Severity: Medium

Issue 5: Empty storage.type falls back to scanning the entire starter/zeta tree, loading s3 and oss jars together and reintroducing the classpath conflict the split layout is meant to eliminate

  • Location: seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:128
  • Why it matters: - Root cause: if (storageType == null || storageType.trim().isEmpty()) { return searchJarFiles(zetaDirectory); } short-circuits before any split-layout detection. In the official package starter/zeta/s3 and starter/zeta/oss now both exist, so an unset/blank storage.type loads the AWS and Aliyun SDK stacks (including their conflicting transitive dependencies such as Netty, per the earlier review discussion on this PR) into the same storage classloader.
  • Impact: users who rely on the default configuration (no storage.type set) get every backend's jars merged together, hitting the exact dependency-conflict scenario the split layout is designed to prevent. The illegal-type fallback at line 142 has the same problem.
  • Evidence: seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:142 return searchJarFiles(zetaDirectory);
  • Suggested fix: With the new dist layout, starter/zeta/s3 and starter/zeta/oss both ship in the official package, so this whole-tree fallback for an empty storage.type loads the AWS and Aliyun SDK stacks into the same classloader — exactly the dependency-conflict scenario the split layout is designed to prevent. When common/ exists, please restrict the empty-type path to common/ + root depth-1 jars, and keep the full recursive scan only for the true legacy layout (no common/ directory). The illegal-type fallback at line 142 has the same issue.
  • Severity: Medium

Issue 6: toRealPath() can throw IOException (dangling symlink, TOCTOU deletion, permission error) and abort engine startup instead of failing closed as documented

  • Location: seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:94
  • Why it matters: - Root cause: isContainedDirectory checks Files.isDirectory(directory) and then calls directory.toRealPath(); similarly searchJarFilesForStorage calls zetaDirectory.toRealPath() unguarded. Between the existence check and toRealPath(), the directory can be removed, or the path can be a symlink whose target becomes unreachable, or the real-path resolution can fail due to permissions — all of which throw IOException rather than returning false.
  • Impact: the exception propagates out of searchJarFilesForStorage and can abort CheckpointService bootstrap during engine startup, whereas every other invalid input in this method degrades to a warning plus a fallback scan.
  • Evidence: seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:147 Path zetaRealPath = zetaDirectory.toRealPath();; seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:91-93 if (!Files.isDirectory(directory)) { return false; }
  • Suggested fix: directory.toRealPath() throws IOException if the directory disappears between the Files.isDirectory check and this call, or if it is a symlink with an unreachable target. That exception propagates all the way up and can abort CheckpointService bootstrap, whereas every other invalid input in this method degrades to a warning + fallback. Please catch IOException here (and around zetaDirectory.toRealPath() at line 147), log a warning, and return false / fall back to the legacy scan so the method actually fails closed as its Javadoc promises.
  • Severity: Medium

Issue 7: Missing storage-specific directory in a split layout is silently ignored, deferring the failure to a hard-to-diagnose ClassNotFoundException at checkpoint init

  • Location: seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:161
  • Why it matters: - Root cause: in searchJarFilesForStorage, splitLayoutDetected becomes true as soon as common/ exists. If the user configures storage.type: oss but the distribution only ships common/ and s3/ (or the directory casing differs on a case-sensitive filesystem after toLowerCase(Locale.ROOT) normalization), the method returns only common + root-level jars with an INFO log that reads like success ("Loaded N storage JAR(s) for storage type 'oss'").
  • Impact: the engine starts, and the failure surfaces much later as a ClassNotFoundException during checkpoint storage initialization, far from the actual misconfiguration and with no startup-time signal pointing at the missing directory.
  • Evidence: seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:156-159 if (isContainedDirectory(storageDir, zetaRealPath)) { splitLayoutDetected = true; jars.addAll(searchJarFiles(storageDir)); }; seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:161-163 if (splitLayoutDetected) { // Keep root-level jars visible ... jars.addAll(searchJarFiles(zetaDirectory, 1));
  • Suggested fix: When common/ exists but the directory for the configured storage.type does not (missing from the assembly, or a casing mismatch after toLowerCase(Locale.ROOT) on a case-sensitive FS), we still report "Loaded {} storage JAR(s) for storage type '{}'" and proceed with only common + root jars. The real failure then shows up much later as a ClassNotFoundException during checkpoint storage init. Please add an explicit log.warn here when splitLayoutDetected is true but the storage-specific directory was not found, naming the expected path (starter/zeta/<type>), so the misconfiguration is visible at startup.
  • Severity: Medium

Issue 8: Docs lack an upgrade note for existing deployments that already have the storage jars in lib/

  • Location: docs/en/engines/zeta/hybrid-cluster-deployment.md:349
  • Why it matters: - Root cause: the new notices state "You do not need to add them to lib/ again when using the packaged distribution", but this is a user-facing behavior change for people upgrading from older releases where the deployment docs explicitly told them to place these jars in lib/. Nothing tells those users whether leftover copies in lib/ are harmless or must be removed.
  • Impact: after upgrading, the same shaded Hadoop/OSS/S3 classes can be present both on the parent classpath (lib/) and in the new storage classloader, which can defeat the classloader isolation this PR introduces and confuse troubleshooting.
  • Evidence: docs/en/engines/zeta/separated-cluster-deployment.md:311 starter/zeta/commonandstarter/zeta/oss. You do not need to add them to lib/ again when
  • Suggested fix: Older versions of this page instructed users to copy these jars into lib/, so upgraded clusters will often have them in both lib/ and the new starter/zeta/* directories. Please add an explicit upgrade note here: should users remove the old copies from lib/, or is it safe to keep them? Duplicate copies on the parent classpath can defeat the classloader isolation this PR introduces.
  • Severity: Medium

Review conclusion

Conclusion: final approval remains pending on the previous comments

2. Remaining follow-ups

  • Issue 1: Once the split layout is detected, jars in non-matching subdirectories of starter/zeta are silently dropped — an upgrade regression for users who nested custom storage jars (e.g. COS) under starter/zeta
  • Issue 2: Symlink containment is only enforced at the top-level directory; the JAR walk still follows nested symlinks (and symlinked *.jar files) out of the starter/zeta root, contradicting the isContainedDirectory guarantee
  • Issue 3: An invalid storage.type silently widens the scan to the entire starter/zeta tree; the "fail closed" comment is inaccurate and misconfiguration reintroduces the exact classpath-conflict problem this PR fixes
  • Issue 4: Fallback paths (empty or illegal storage.type) scan the whole zeta directory, loading conflicting storage stacks (s3 + oss) into one classloader and bypassing the symlink containment check
  • Issue 5: Empty storage.type falls back to scanning the entire starter/zeta tree, loading s3 and oss jars together and reintroducing the classpath conflict the split layout is meant to eliminate
  • Issue 6: toRealPath() can throw IOException (dangling symlink, TOCTOU deletion, permission error) and abort engine startup instead of failing closed as documented
  • Issue 7: Missing storage-specific directory in a split layout is silently ignored, deferring the failure to a hard-to-diagnose ClassNotFoundException at checkpoint init
  • Issue 8: Docs lack an upgrade note for existing deployments that already have the storage jars in lib/

Thanks for the updates so far. Happy to discuss the remaining points.

@DanielLeens

Copy link
Copy Markdown
Contributor

Hi @SEZ9, thanks for the detailed follow-up pass. I independently re-read seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java on the current head (77afe1b29dee) before replying, rather than taking the findings at face value.

Issue 2 (nested-symlink escape via FOLLOW_LINKS) is correct, and it's a real gap in my own prior review. isContainedDirectory() (FileUtils.java:89-104) only resolves and checks the top-level common//<type>/ directory against zetaRealPath. Once that check passes, searchJarFiles(commonDir) / searchJarFiles(storageDir) walk with Files.walk(directory, maxDepth, FileVisitOption.FOLLOW_LINKS) (FileUtils.java:59) at unbounded depth, and nothing re-checks containment per-entry during that walk. A symlink nested inside an already-contained directory (e.g. common/deps -> /opt/attacker) or a symlinked .jar file anywhere under it would still be picked up. My August 24 review only re-derived the three vectors from the original July 26 finding (string traversal, absolute path, top-level symlink) and didn't check whether containment survives the recursive walk — it doesn't. Conceding this one; it should be a blocking item, not non-blocking, since it defeats the containment guarantee the Javadoc at lines 84-87 claims. Fix direction I'd suggest: check path.toRealPath().startsWith(zetaRealPath) per candidate inside the walk (or run the storage-layout walk without FOLLOW_LINKS, since legitimate storage JARs won't be symlinked).

Issues 3/4/5 (empty or illegal storage.type fall back to a full recursive scan) are also confirmed in the code (FileUtils.java:127-128, 136-142) — that path does merge common/ + s3/ + oss/ into one classloader, which is the isolation problem this PR sets out to fix, and the "Fail closed" comment on line 135 is misleading since it's actually the widest possible scan. I'd treat these as legitimate non-blocking-but-should-fix items (not the same severity as Issue 2, since this doesn't cross a filesystem trust boundary the way the symlink escape does — it's a design gap in the default/misconfigured case, not a path-containment bypass).

Issue 6 (unguarded toRealPath() IOException) and Issue 7 (missing storage dir silently degrades to common+root with a success-shaped log) both check out against the current source too — no catch around either toRealPath() call, and the splitLayoutDetected branch doesn't distinguish "storage dir found" from "storage dir missing, only common/root loaded."

On the CI-blocking compile break I flagged in my own August 24 review (JobStateEventTest.java:165, FAILED_JOB_EVENT_TIMEOUT_SECONDS undefined): I re-checked dev just now and it's already fixed there — dev commit 43fe63b1fc ("[Fix][Zeta] Fix undefined job event timeout constant (#11954)") is on the current dev HEAD. So the concrete next step for @corgy-w is to rebase/sync this branch onto the latest dev and rerun Build; that specific compile break should be gone, and this PR's own new tests (CheckpointServiceStorageClassLoaderTest, FileMapStoreTest) will finally get to run in CI, which they haven't yet in any run so far.

Given the above, I'm revising my prior "no High/blocking items in this PR's own diff" conclusion: Issue 2 should be treated as a blocking item alongside getting a clean, fully-executed CI run. Issues 1/3/4/5/6/7/8 remain valid non-blocking follow-ups worth addressing in the same pass. Thanks again for the thorough re-check, @SEZ9 — this is exactly the kind of independent verification that catches what a single reviewer misses.

Resolve the merge conflicts with dev: keep both sides' additions (imports, constants and tests) and apply the project formatter.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @corgy-w for syncing the branch with dev. I re-read the full diff and re-traced the call chain on the current head a8c899d93394. Sorry for missing one of the items below in my earlier rounds (details in Issue 2): that is on me, it is a carryover from the previous version of the diff and not something this merge introduced, and I only noticed it now because the test finally got to run in CI.

What changed since my last review: the head moved only through the merge of dev (merge commit a8c899d93394, 2026-10-05). I diffed the PR's own change set at the head I last reviewed (77afe1b29dee) against the current one: the 15 files are identical apart from shifted hunk offsets and one import line that dev now provides itself, so the author code is unchanged.

What Problem Does This PR Solve?

  • User pain point: Zeta's checkpoint and IMAP storage backends (S3, OSS, ...) all put their Hadoop/SDK jars into one flat classpath, so their dependency trees (for example the OSS SDK and its Netty version) can collide with each other and with connector dependencies.
  • Fix approach: Package storage jars under starter/zeta/{common,s3,oss} and have CheckpointService / FileMapStore build a scoped URLClassLoader from common/ plus the directory that matches storage.type before SPI discovery, falling back to the legacy whole-directory scan when the split layout is absent.
  • One-sentence summary: Storage-dependency isolation for Zeta checkpoint/IMAP storage with a backward-compatible layout.

1. Code Change Review

1.1 Core Logic Analysis

Zeta server start
  -> new CheckpointService(config)                                CheckpointService.java:64 -> :74
       -> FileUtils.searchJarFilesForStorage(starter/zeta, storage.type)   FileUtils.java:134
            -> null/empty or illegal storage.type -> searchJarFiles(zetaDirectory)   FileUtils.java:142 / :156
            -> zetaDirectory.toRealPath()                         FileUtils.java:161
            -> isContainedDirectory(common/) , isContainedDirectory(<type>/)   FileUtils.java:164 / :170
                 -> searchJarFiles(dir) = Files.walk(..., FOLLOW_LINKS)        FileUtils.java:73
            -> root-level jars at depth 1                         FileUtils.java:177
       -> new URLClassLoader(jars, parent)                        CheckpointService.java:82
       -> FactoryUtil.discoverFactory(...) under TemporaryClassLoaderContext
  -> FileMapStore.init(...) does the same for IMAP storage        FileMapStore.java:82-86

Key findings:

  • The normal user path (Zeta with the official dist) hits this logic on every start, so the containment guard and the new tests matter.
  • The traversal / absolute-path / top-level-symlink vectors from the July review are closed by STORAGE_TYPE_PATTERN plus isContainedDirectory (FileUtils.java:95, :103).
  • The dev-baseline compile break I flagged on 2026-08-24 is gone now that dev has the fix, so the new engine tests are finally executed in CI. That is how Issue 2 surfaced.

1.2 Compatibility Impact

Partially incompatible, but mitigated. The legacy flat starter/zeta layout still works through the fallback. The one behavior change is already noted by @SEZ9 (non-blocking Issue 1 in their review): once common/ exists, jars in other sub-directories that the old recursive scan used to pick up are skipped. A WARN plus an upgrade note would be enough.

1.3 Performance / Side-Effect Analysis

One extra directory walk and one URLClassLoader per service at startup; negligible. The loader is intentionally kept for the process lifetime because the storage factory lives that long.

1.4 Error Handling and Logging

The toRealPath() calls are unguarded and the missing-storage-directory case degrades to common/ + root with a success-shaped INFO log; both are covered by @SEZ9's non-blocking items 6 and 7 below.

Issue 1: Containment is only enforced for the top-level directories; the jar walk still follows nested symlinks out of starter/zeta (High, blocking)

  • Location: seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/FileUtils.java:73 (walk), :164-171 (containment check)
  • Problem: isContainedDirectory resolves only common/ and <type>/, then searchJarFiles walks them at unbounded depth with FOLLOW_LINKS. A symlinked sub-directory (for example common/deps -> /somewhere/else) or a symlinked *.jar, including at the depth-1 root scan (:177), resolves outside the root and is still loaded into the engine classloader. This defeats the guarantee the Javadoc on isContainedDirectory states.
  • Risk: Jars from unrelated filesystem locations end up in the engine classpath.
  • Best improvement: Option A: check path.toRealPath().startsWith(zetaRealPath) for each candidate inside the walk. Option B: walk the split-layout directories without FOLLOW_LINKS (legitimate storage jars should not be symlinks). Please add a test for a nested symlink.
  • Severity: High
  • Raised by another reviewer: Yes, @SEZ9 (their Issue 2, review 5018047225); I verified it against the source and agreed in my follow-up comment. +1, still present on this head.

Issue 2: CheckpointServiceStorageClassLoaderTest fails deterministically on Windows (High, blocking, test stability)

  • Location: seatunnel-engine/seatunnel-engine-server/src/test/java/org/apache/seatunnel/engine/server/CheckpointServiceStorageClassLoaderTest.java:45 (@TempDir) and :64 (new CheckpointService(checkpointConfig, zetaDirectory)); production side CheckpointService.java:82
  • Evidence: both unit-test (8, windows-latest) and unit-test (11, windows-latest) fail in the fork run 37392693060 with testLoadsCheckpointFactoryFromZetaStarterJar -> java.io.IOException: Failed to delete temp directory ... The following paths could not be deleted: , zeta, zeta\s3.
  • Problem: The test creates a jar under @TempDir, and CheckpointService opens it through a URLClassLoader that is intentionally never closed. On Windows an open jar cannot be deleted, so the JUnit temp-dir cleanup fails and the test errors even though the assertion passed.
  • Best improvement: Option A (smallest): mark the test @EnabledOnOs({OS.LINUX, OS.MAC}), which is exactly what FileMapStoreTest in this PR already does; the isolation logic is OS-independent. Option B (keeps Windows coverage): have the @VisibleForTesting constructor path expose or retain the created loader so the test can close it before cleanup.
  • Severity: High (a Windows lane that fails on every run blocks the merge gate)
  • Raised by another reviewer: No. Sorry again for rating the tests Stable earlier: the Windows jar-lock was visible in the source at that time and I should have caught it.

Non-blocking items I agree with (from @SEZ9's review): Issue 1 (sub-directories silently skipped once common/ exists), Issues 3/4/5 (empty or illegal storage.type falls back to a full recursive scan, which contradicts the "fail closed" comment at FileUtils.java:150-156), Issue 6 (unguarded toRealPath()), Issue 7 (missing storage directory only logs INFO). I still consider these should-fix follow-ups rather than blockers for this change.

2. Code Quality Assessment

2.1 Coding Standards

Core methods are documented; the Javadoc on isContainedDirectory is accurate about intent (see Issue 1 for the gap).

2.2 Test Coverage and Test Stability

FileUtilsTest covers traversal, absolute path and top-level symlink containment (the symlink case is correctly @DisabledOnOs(WINDOWS)); FileMapStoreTest is Linux/Mac only. Stability rating: High risk because of Issue 2 (deterministic Windows failure). Missing coverage: a nested-symlink case for Issue 1.

2.3 Documentation Updates

EN and ZH docs are updated consistently for the new layout.

3. Architectural Soundness

  • 3.1 Elegance: Precise fix for the dependency-collision problem, with a legacy fallback.
  • 3.2 Maintainability: Reasonable once the fallbacks are made explicit (non-blocking items above).
  • 3.3 Extensibility: New storage types only need a new directory in the assembly.
  • 3.4 Historical-version compatibility: See 1.2.

4. Issue Summary

# Issue Location Severity
1 Nested symlinks escape the containment check FileUtils.java:73, :164-177 High
2 Windows unit tests fail: unclosed URLClassLoader blocks @TempDir cleanup CheckpointServiceStorageClassLoaderTest.java:45, :64 High

5. Merge Recommendation

Conclusion: Ready to merge after fixes

  1. Blockers - must be fixed: Issue 1 (+1 to @SEZ9), Issue 2.
  2. Recommended fixes - non-blocking: @SEZ9's items 1, 3-7 listed above.

CI / merge-gate status on the current head (checked just now): Build is red. The two Windows unit-test jobs are explained by Issue 2. The third red job, engine-v2-it (8, ubuntu-latest), failed in SplitClusterPendingJobLifecycleFailoverIT.testMasterElectionLoopRecoversFromRapidFailoverChurn (a master-election churn test); this PR does not touch election code, so I read it as an unrelated flake (an inference from the log, not reproduced), and it is worth re-running only that failed job after the fixes. A sync with dev is not the missing step here: the branch is 43 commits behind but has no conflicts, and the compile break is already fixed. The remaining gate after the fixes is a green run plus the required committer approval (REVIEW_REQUIRED).

Thanks again for the careful and well-documented work on this, and I am happy to re-review as soon as you push an update.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api core SeaTunnel core module document Zeta

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants