You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2026/06/25 01:34:00 UTC
[jira] [Updated] (FLINK-39687) URI used as URL in SessionContext causes ArrayStoreException
[ https://issues.apache.org/jira/browse/FLINK-39687?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
ASF GitHub Bot updated FLINK-39687:
-----------------------------------
Labels: pull-request-available (was: )
> URI used as URL in SessionContext causes ArrayStoreException
> ------------------------------------------------------------
>
> Key: FLINK-39687
> URL: https://issues.apache.org/jira/browse/FLINK-39687
> Project: Flink
> Issue Type: Bug
> Components: Table SQL / Gateway
> Reporter: tonyabasy
> Priority: Major
> Labels: pull-request-available
>
> h2. Location
> {{flink-table/flink-sql-gateway/src/main/java/org/apache/flink/table/gateway/service/context/SessionContext.java}} line 306
> h2. Faulty Code
> {code:java}
> defaultContext.getDependencies().toArray(new URL[0]) {code}
> h2. Root Cause
> {{DefaultContext.getDependencies()}} returns {{List<URI>}} ({{{}java.net.URI{}}}), but the code calls {{{}.toArray(new URL[0]){}}}.
> {{java.net.URI}} and {{java.net.URL}} are *completely unrelated classes* (no inheritance relationship), so a {{URL[]}} array cannot hold {{URI}} objects.
> Java's {{List.toArray(T[])}} generic method does not check element type compatibility at compile time, so this compiles successfully. However, it will *always throw {{ArrayStoreException}} at runtime* when the {{toArray}} implementation attempts to store a {{URI}} into a {{{}URL[]{}}}.
> h2. When It Triggers
> This bug triggers when {{defaultContext.getDependencies()}} returns a non-empty list. It currently goes unnoticed because:
> * {{DefaultContext.load()}} creates a DefaultContext with an empty dependency list (the {{dependencies}} parameter is always empty in current callers)
> * {{ScriptRunner}} passes {{Collections.emptyList()}} directly (empty array, {{toArray}} never needs to store elements, so no exception)
> Once anyone creates a DefaultContext with non-empty dependencies, the exception will fire.
> h2. Fix
> Convert each {{URI}} to {{URL}} individually:
> {code:java}
> defaultContext.getDependencies().stream()
> .map(uri -> uri.toURL())
> .toArray(URL[]::new) {code}
> h2. Introduced In
> FLINK 2.2.0 (commit: 5a336892424)
--
This message was sent by Atlassian Jira
(v8.20.10#820010)