Skip to content

[SPARK-57081][TESTS] Fix percent-encoding issue in SparkTestUtils classpath handling#56125

Open
sarutak wants to merge 3 commits into
apache:masterfrom
sarutak:fix-percent-encoding-issue
Open

[SPARK-57081][TESTS] Fix percent-encoding issue in SparkTestUtils classpath handling#56125
sarutak wants to merge 3 commits into
apache:masterfrom
sarutak:fix-percent-encoding-issue

Conversation

@sarutak
Copy link
Copy Markdown
Member

@sarutak sarutak commented May 26, 2026

What changes were proposed in this pull request?

This PR replaces URL.getFile() with new File(url.toURI).getPath (or new File(url.toURI)) in SparkTestUtils.scala to correctly handle classpath URLs containing percent-encoded characters (e.g., spaces encoded as %20).

Four call sites are fixed:

  • createCompiledClass
  • createJarWithJavaSources
  • createJarWithScalaSources
  • expandManifestClasspath

Additionally, a new test suite SparkTestUtilsSuite is added to cover both this fix and the expandManifestClasspath logic introduced in #55564.

Why are the changes needed?

URL.getFile() returns a percent-encoded string. When a classpath URL contains spaces or special characters (e.g., C:\Program Files\... or CI environments with spaces in paths), the encoded string (e.g., /path%20with%20spaces/lib.jar) is passed directly to the compiler or new File(...), which fails to resolve the actual file. Using url.toURI properly decodes the path.

Without this change, tests which use SparkTestUtils fails if the repository is in the path containing white spaces.

$ build/sbt 'core/testOnly org.apache.spark.executor.ClassLoaderIsolationSuite
...

[info] - SPARK-51537 Executor isolation avoids reloading plugin jars *** FAILED *** (1 second, 674 milliseconds)
[info]   java.lang.AssertionError: assertion failed: Compiled file not found: /private/space containing path/spark/core/TestExecutorPlugin.class

...

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Confirmed ClassLoaderIsolationSuite passed even if the repository is in a space containing path.

Was this patch authored or co-authored using generative AI tooling?

Generated-by: Claude (via Kiro CLI, auto model selection)

sarutak added 3 commits May 27, 2026 01:35
Replace URL.getFile() with new File(url.toURI).getPath in SparkTestUtils.scala to correctly handle classpath URLs containing percent-encoded characters (e.g., spaces encoded as %20).

URL.getFile() returns percent-encoded strings, so paths containing spaces or special characters are not resolved correctly when passed to File constructors or compiler classpath arguments. Using url.toURI properly decodes the path.

Four call sites are fixed:
- createCompiledClass
- createJarWithJavaSources
- createJarWithScalaSources
- expandManifestClasspath
Copy link
Copy Markdown
Member

@dongjoon-hyun dongjoon-hyun left a comment

Choose a reason for hiding this comment

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

+1, LGTM.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants