Skip to content

[FLINK-39687] [sql-gateway] Fix URI dependency conversion in SessionContext#28529

Open
qiuyanjun888 wants to merge 2 commits into
apache:masterfrom
qiuyanjun888:fix/flink-39687-20260625-084608-a1
Open

[FLINK-39687] [sql-gateway] Fix URI dependency conversion in SessionContext#28529
qiuyanjun888 wants to merge 2 commits into
apache:masterfrom
qiuyanjun888:fix/flink-39687-20260625-084608-a1

Conversation

@qiuyanjun888

Copy link
Copy Markdown

What is the purpose of the change

This pull request fixes SessionContext creation when the default SQL Gateway context contains dependency URIs. The previous code passed List<URI> elements to toArray(new URL[0]), which throws ArrayStoreException as soon as the dependency list is non-empty.

Brief change log

  • Convert each dependency URI to a URL before creating the session user-code classloader.
  • Add a SessionContextTest regression test that creates a session from a DefaultContext with a non-empty dependency list and verifies the dependency URL is available from the user-code classloader.

Verifying this change

This change added tests and can be verified as follows:

  • ./mvnw -pl flink-table/flink-sql-gateway -Dtest=SessionContextTest#testCreateContextWithDependencies -DfailIfNoTests=false -Dsurefire.failIfNoSpecifiedTests=false -Dfast test
  • ./mvnw -pl flink-table/flink-sql-gateway -Dtest=SessionContextTest -Dfast test
  • ./mvnw -pl flink-table/flink-sql-gateway spotless:check checkstyle:check

I also verified that the new regression test fails against the previous production implementation with java.lang.ArrayStoreException: java.net.URI.

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): no
  • The public API, i.e., is any changed class annotated with @Public(Evolving): no
  • The serializers: no
  • The runtime per-record code paths (performance sensitive): no
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no
  • The S3 file system connector: no

Documentation

  • Does this pull request introduce a new feature? no
  • If yes, how is the feature documented? not applicable

Was generative AI tooling used to co-author this PR?
  • Yes (Hermes Agent / OpenAI GPT-5.5)

Generated-by: Hermes Agent / OpenAI GPT-5.5

@flinkbot

flinkbot commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

private static URL toURL(URI uri) {
try {
return uri.toURL();
} catch (MalformedURLException e) {

@spuru9 spuru9 Jun 25, 2026

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.

nit: a plain --jar foo.jar is a schemeless URI, so toURL() throws IllegalArgumentException, not MalformedURLException — dodges this catch. Add it?

Suggested change
} catch (MalformedURLException e) {
} catch (MalformedURLException | IllegalArgumentException e) {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed by catching IllegalArgumentException alongside MalformedURLException and wrapping it in SqlGatewayException; added a regression test for URI.create("foo.jar").

Verification: ./mvnw -pl flink-table/flink-sql-gateway -Dtest=SessionContextTest test -DfailIfNoTests=false passed, and git diff --check passed.

@github-actions github-actions Bot added the community-reviewed PR has been reviewed by the community. label Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-reviewed PR has been reviewed by the community.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants