felipepessoto opened a new pull request, #13822:
URL: https://github.com/apache/gluten/pull/13822
<!-- copilot-assessment:v1 -->
### Agent assessment
Self-reported assessment, not an independent review.
Assessed revision: `d98008bc9c7e3789dab7f6b23dfa320abea231c8`
| Dimension | Assessment | Rationale |
|---|---|---|
| Change confidence | 9/10 | ↑ All 23 native JNI exception tests pass,
including 2 new boundary tests.<br>↑ 4 injected faults each fail the new tests:
describing after a carried Java cause or with a pending throwable, a leaked
registration, and an escaping provider failure.<br>↑ `JavaExceptionJniTest`
passes 17/17 on Spark 3.5 and 4.1 under `-Xcheck:jni`, with no JNI warnings.
`GlutenJniExceptionSuite` passes 8/8 on Spark 4.1.<br>↓ No backend registers a
provider yet, so only tests exercise the typed path.<br>↓ Fork CI has not run
on this revision. |
<!-- /copilot-assessment -->
<!--
Thank you for submitting a pull request! Here are some tips:
1. For first-time contributors, please read our contributing guide:
https://github.com/apache/gluten/blob/main/CONTRIBUTING.md
2. If necessary, create a GitHub issue for discussion beforehand to avoid
duplicate work.
3. If the PR is specific to a single backend, include [VL] or [CH] in the PR
title to indicate the
Velox or ClickHouse backend, respectively.
4. If the PR is not ready for review, please mark it as a draft.
-->
## What changes are proposed in this pull request?
<!--
Provide a clear and concise description of the changes introduced in this PR.
Ensure the PR description aligns with the code changes, especially after
updates.
If applicable, include "Fixes #<GitHub_Issue_ID>" to automatically close the
corresponding issue
when the PR is merged.
-->
This lets a backend raise its own Java exception type for a native error at
the JNI return boundary, instead of the generic `GlutenException`.
- `JniExceptionMetadataRegistration(ExceptionMetadataProvider)` registers a
callback for the backend library's lifetime. It has the same null check,
duplicate check and scoped unregistration as
`JniExceptionUnwrapperRegistration`. The two registrations now share that code,
and the unwrapper's API and behavior are unchanged.
- The callback describes a native `std::exception` as a JNI class name, a
reason and a diagnostic, or returns `std::nullopt`. The strings are owned, and
the callback must not call JNI.
- `handleJniException` asks the providers only when no Java exception is
pending and the error carries no Java throwable, so those keep precedence.
After releasing the registry lock, it constructs the class through its `(byte[]
reason, byte[] diagnostic)` constructor and throws it. The byte arrays carry
the UTF-8 bytes unchanged, including NULs.
- This is best effort. A Java exception raised while constructing the
throwable, such as `OutOfMemoryError` or `NoClassDefFoundError`, stays pending.
Any other failure keeps the `GlutenException` fallback with the original
diagnostic.
No backend registers a provider in this PR, so behavior doesn't change.
#13135 uses this hook to raise a typed exception for Velox cast failures.
## How was this patch tested?
<!--
Describe how the changes were tested, if applicable.
Include new tests to validate the functionality, if necessary.
For UI-related changes, attach screenshots to demonstrate the updates.
-->
New tests:
- `JniExceptionMetadataTest` (C++, in `JavaExceptionTest.cc`): a pending
throwable wins, a carried Java throwable wins without asking the provider, a
provider failure keeps the original diagnostic, and the registration is scoped.
- `JavaExceptionJniTest` (real JVM): the typed exception keeps an embedded
NUL, a constructor failure stays pending, and a failed throw falls back to
`GlutenException` with the original diagnostic. It uses test-only exception
classes.
I ran these in the `apache/gluten:centos-9-jdk17` image, with the Velox
version that `main` pins:
- The 23 `JavaExceptionTest`, `JniExceptionMetadataTest`,
`JavaExceptionAllocationTest` and `VeloxJavaExceptionTest` cases.
- `JavaExceptionJniTest` (17 cases) on Spark 3.5 and 4.1, and
`GlutenJniExceptionSuite` (8 cases) on Spark 4.1, all with `-Xcheck:jni`.
- `dev/format-cpp-code.sh` (clang-format 15.0.7),
`dev/format-scala-code.sh`, the license header check and checkstyle.
## Was this patch authored or co-authored using generative AI tooling?
<!--
If generative AI tooling has been used in the process of authoring this
patch, please include the
phrase: 'Generated-by: ' followed by the name of the tool and its version.
If no, write 'No'.
Please refer to the [ASF Generative Tooling
Guidance](https://www.apache.org/legal/generative-tooling.html) for details.
-->
Generated-by: GitHub Copilot 1.0.115-7 (Claude Opus 5.5, model ID:
claude-opus-5.5)
--
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]