LeonxLJX commented on PR #19784:
URL: https://github.com/apache/hudi/pull/19784#issuecomment-5551083796
Updated the implementation to actually fix #14554 — the previous commit only
replaced `InputStream.transferTo` with a buffered copy loop, which made the
Scala 2.12 / Java 8 toolchain compile but did not address the underlying
`URI is not hierarchical` failure the bundle `Main` callers see.
New implementation:
- Reads `jar:` URLs through `JarURLConnection` rather than converting them
to `File`, with `setUseCaches(false)` so the backing `JarFile` is not
shared with other readers in the JVM.
- Replaces the recursive directory walk with `Files.walk`.
- `getResources` throwing `IOException` returns an empty stream instead of
an NPE from the following `Objects.requireNonNull`.
- A class with no package (arrays, primitives) returns an empty stream
instead of an NPE from `Class.getPackage()`.
Five new unit tests cover both protocols and the negative cases:
- `testGetTopLevelClassesInClasspathFromDirectory` — exploded directory
fixture, `file:` protocol, asserts only the three classes in the
fixture (top-level, sibling, subpackage) are returned; the README.txt
non-class file is excluded.
- `testGetTopLevelClassesInClasspathFromJar` — jar fixture built with
`JarOutputStream`, `jar:` protocol, same negative-case assertion.
- `testGetTopLevelClassesInClasspathOnTheRealClasspath` — sanity check
against the production package on the Maven classpath.
- `testGetTopLevelClassesInClasspathForClassesWithoutAPackage` — `int[]`
and `int.class`, asserting the empty-stream contract.
- `testGetTopLevelClassesInClasspathForPackageNotOnTheClasspath` —
filtering against an absent prefix.
The fixture classes are written with a stub class-file header (the scanner
only inspects JAR entry names, never bytecode) so the test does not need
to invoke `javac`.
This converges on the same shape as #19624 (deepakpanda93); happy to close
in favour of that one if a committer prefers. The full hudi-io suite
reported in #19624 should apply.
I do not have a Maven toolchain on the machine I am working from, so I
have not been able to run the test suite myself. CI on the new head
(commit `1487074f`) is currently in the `action_required` state waiting
for a maintainer to approve the first run on this fork — would be
grateful for the click.
--
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]