Olawoyin007 opened a new pull request, #1033:
URL: https://github.com/apache/flink-agents/pull/1033
## What is the purpose of the change
Fixes #966.
A Flink deployment can add user-code JARs relative to the TaskManager
working directory, so a classloader may expose a skill resource through a
**relative** `file:` URL such as `file:../../flink/usrlib/job.jar` (or
`jar:file:../../flink/usrlib/job.jar!/diagnosis-skills`). Such a URL parses to
an *opaque* `URI`, which `new File(URI)` / `Paths.get(URI)` reject with
`IllegalArgumentException: URI is not hierarchical`, so
`ClasspathSkillRepository` initialization fails and skills never load.
## Brief change log
- Add `LocalUrls.toLocalFile(URL)`, a single place that converts a local
`file:` URL to a `File`:
- absolute hierarchical `file:` URLs keep their existing `new File(uri)`
behavior;
- opaque relative `file:` URLs are resolved against the process working
directory via the decoded scheme-specific part;
- non-`file` URLs are rejected explicitly.
- Reuse it in the three affected sites so their behavior can't drift:
- `ClasspathSkillRepository.materializeFileUrl` (direct file/dir/zip
resource),
- `SkillMaterializer.copyJarEntries` (JAR entry extraction),
- `ClasspathSkillRepository.findAllMatches` (`URLClassLoader` fallback
scan).
- Remove now-unused imports.
## Verifying this change
- New `LocalUrlsTest` covers absolute resolution, relative/opaque resolution
against the working directory, and non-`file` rejection.
- New `ClasspathSkillRepositoryTest#loadFromRelativeJarUrl` loads skills
end-to-end through a relative jar URL (exercises both the fallback scan and jar
extraction). Verified that this test fails against the pre-fix code with the
reported `Classpath resource not found` / `URI is not hierarchical` error.
- Full `runtime` module test suite passes (668 tests, 0 failures).
## Does this pull request potentially affect one of the following parts
- Dependencies (does it add or upgrade a dependency): **no**
- The public API: **no**
- The serializers: **no**
- The runtime per-record code paths: **no**
- Anything that affects deployment or recovery: **no**
- The threading model: **no**
## Documentation
- Does this pull request introduce a new feature? **no**
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]