Skip to content

[UT] ComponentClassLoaderTest fails when java.io.tmpdir contains dots #3437

Description

@litiliu

Describe the bug

ComponentClassLoaderTest.testOwnerFirstResourceFoundIgnoresComponent can fail in CI when java.io.tmpdir points to a path that contains dots, for example a temporary directory containing a version-like segment such as 1.0-SNAPSHOT.

In this case ComponentClassLoader#getResource(...) returns null, and the test fails because the loaded resource is expected to be the owner class loader resource.

Reproduction

Run the fluss-common test module with a temp directory whose path contains dots, for example:

mvn -pl fluss-common -Dtest=ComponentClassLoaderTest -Djava.io.tmpdir=/tmp/fluss-1.0-SNAPSHOT test

Root cause

The test uses the @TempDir absolute path as both the resource name and the owner-first package/resource prefix.

ComponentClassLoader converts package prefixes to resource path prefixes by replacing . with /. If the temp path contains a segment such as 1.0-SNAPSHOT, it is converted to 1/0-SNAPSHOT, so the owner-first resource prefix no longer matches the actual resource name. As a result, the owner-first resource lookup is skipped and getResource(...) returns null.

Expected behavior

The test should not depend on the formatting of the machine-specific temporary directory path. It should use a stable package/resource prefix and create an explicit test resource under the temp directory.

Affected test

fluss-common/src/test/java/org/apache/fluss/classloading/ComponentClassLoaderTest.java

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions