Fix: JNI error path cleanup - #129
Open
redaranj wants to merge 3 commits into
Open
Conversation
The resolver body only checked for a pending exception after the resolve() call itself. The request-side conversions (string transcoding, body array allocation and copy) and the response-side getters (getStatus, getBody, the body copy) were unchecked, so an app-side exception there left the JVM with an exception pending across further JNI calls, which is undefined behavior, and let a garbage status or body reach the core. Check each step: marshalling failures skip the bridge call, and every response read stashes a pending exception for the outer boundary, releases its local refs and the half-built body buffer, sets a specific core error string, and returns -1. Co-Authored-By: Claude Fable 5 <[email protected]>
Stream creation threw a raw RuntimeException from the JNI when the core could not allocate a stream, and C2PA.version() was declared non-null although the string bridge returns NULL on allocation failure, which would have surfaced as a NullPointerException. Both were left over from the sentinel-return conversion because neither had a wrapper declaring C2PAError. Return 0 from createStreamNative and raise C2PAError.Api from the Stream constructor; make the version bridge nullable behind a C2PA.version() wrapper that raises C2PAError.Api. The JNI no longer throws RuntimeException anywhere, and every external declaration returning an object type is nullable. Co-Authored-By: Claude Fable 5 <[email protected]>
test-shared declared minSdk 26 while the library and both apps declare 28, the documented minimum. The apps' manifest merge already took the higher value, so this only stops lint in test-shared from accepting API 26 assumptions the library does not support. Co-Authored-By: Claude Fable 5 <[email protected]>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## fix/utf8-string-bridging #129 +/- ##
==============================================================
- Coverage 72.25% 72.14% -0.12%
Complexity 38 38
==============================================================
Files 62 62
Lines 2350 2355 +5
Branches 286 289 +3
==============================================================
+ Hits 1698 1699 +1
- Misses 493 495 +2
- Partials 159 161 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes in this pull request
Checks every JNI call in the HTTP resolver trampoline and routes the last two raw failure paths (Stream creation, C2PA.version()) through C2PAError, so nothing in the JNI throws RuntimeException or leaves an exception pending. Also aligns test-shared minSdk to 28.
Types of changes
Checklist
TO DOitems (or similar) have been entered as GitHub issues and the link to that issue has been included in a comment