Skip to content

[Bug] ParameterizedTestExtension fails on test classes it cannot access #9509

Description

@thswlsqls

Search before asking

  • I searched in the issues and found nothing similar.

Paimon version
master @ da71a66 (2.1-SNAPSHOT)

Compute Engine
Engine-agnostic (paimon-test-utils)

Minimal reproduce step
ParameterizedTestExtension invokes the @Parameters provider and writes @Parameter fields reflectively, but never calls setAccessible(true). A package-private test class breaks it even with a public static provider, because the declaring class itself is not accessible from the extension's package:

@ExtendWith(ParameterizedTestExtension.class)
class MyTest {                                  // package-private
    @Parameter public String value;
    @Parameters public static List<String> parameters() { return Arrays.asList("a"); }
    @TestTemplate void test() {}
}

Result: IllegalAccessException: ... cannot access a member of class ... with modifiers "public static". Private providers and private @Parameter fields fail the same way.

What doesn't meet your expectations?
Parameter injection should work regardless of the test class's and members' visibility.

Anything else?
All 20 usage sites in this repo are public class, necessarily so. About a quarter of the repo's *Test/*ITCase classes are package-private, so that style cannot use this extension. Upstream flink-test-utils-junit, which this file was ported from, added both setAccessible(true) calls (FLINK-32058, FLINK-32942). No existing test breaks today.

Are you willing to submit a PR?

  • I'm willing to submit a PR!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions