hiwuya opened a new pull request, #10861:
URL: https://github.com/apache/ozone/pull/10861
## What changes were proposed in this pull request?
This PR fixes a `NullPointerException` during EC degraded reads when the
Ozone client runs inside an isolated plugin class loader (e.g. Trino Hive
connector).
Normal reads succeed, but when a DataNode is unavailable, the EC degraded
read path fails with:
```
java.lang.NullPointerException:
Cannot read the array length because "<local3>" is null
at org.apache.ozone.erasurecode.rawcoder.util.CodecUtil
.createRawDecoderWithFallback(CodecUtil.java:90)
```
Root cause: `CodecRegistry` loads coder factories via
`ServiceLoader.load(RawErasureCoderFactory.class)`, which uses the **thread
context class loader (TCCL)**. In Trino's isolated plugin class loader, the
TCCL cannot see the Ozone `META-INF/services` providers, so
`getCoderNames("rs")` returns `null`, causing the NPE in `CodecUtil`. Spark
works because its TCCL can see the Ozone providers.
**Fix:** Use `CodecRegistry`'s own class loader instead of the TCCL:
```java
ServiceLoader.load(RawErasureCoderFactory.class,
CodecRegistry.class.getClassLoader());
```
No changes to the singleton pattern, registration logic, native coder
priority, fallback order, or public API.
## What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-15963
## How was this patch tested?
- Added `testRegistryLoadsWithoutTccl`: sets TCCL to an empty
`ClassLoader(null)` before first `CodecRegistry` initialization, then verifies
`getCoderNames("rs")` is non-null, non-empty, and contains `rs_java`. Restores
TCCL in `finally`.
- Confirmed the test fails when the fix is reverted.
- Full `hdds-erasurecode` module test suite: 80 tests pass, 39 native tests
skipped (environment), no regressions.
- Note: This test must run in its own JVM (`reuseForks=false`) due to the
eagerly-initialized singleton.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]