Skip to content

HHH-21002 Handle JSON-B API without a provider - #13706

Open
lucamolteni wants to merge 1 commit into
hibernate:mainfrom
lucamolteni:HHH-21002-jsonb-provider
Open

lucamolteni wants to merge 1 commit into
hibernate:mainfrom
lucamolteni:HHH-21002-jsonb-provider

Conversation

@lucamolteni

@lucamolteni lucamolteni commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Handle an API-only JSON-B classpath during automatic mapper discovery by returning no mapper when provider discovery reports a missing provider.
  • Use standard JSON-B provider discovery, while retaining fail-fast behavior for explicit JSON-B mapper construction and failures when an installed provider creates its builder or JSON-B instance.
  • Add isolated-classloader regression coverage for a missing API, an API without a provider, an installed provider, explicit mapper construction, and a failing provider.

Jira: https://hibernate.atlassian.net/browse/HHH-21002
Reported in quarkusio/quarkus#57388.

Verification

  • ./gradlew formatChecks :hibernate-core:test --tests org.hibernate.orm.test.type.format.JakartaJsonIntegrationTests --tests 'org.hibernate.orm.test.mapping.basic.JsonMappingTests$*' passes: 24 focused tests on both main and 8.0.
  • The API-only regression test fails before the fix and passes afterward.
  • The same fix on ORM 8.0.0-SNAPSHOT successfully builds the Quarkus issue's native reproducer with local Quarkus 999-SNAPSHOT and GraalVM CE 25.0.2, without adding Yasson or quarkus-jsonb. The original build with ORM 8.0.0.Beta3 fails during native-image analysis.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license
and can be relicensed under the terms of the LGPL v2.1 license in the future at the maintainers' discretion.
For more information on licensing, please check here.



Please make sure that the following tasks are completed:
Tasks specific to HHH-21002 (Bug):

  • Add test reproducing the bug
  • Add entries as relevant to migration-guide.adoc OR check there are no breaking changes

@marko-bekhta marko-bekhta left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks 🙂 makes sense 👍🏻


@BeforeEach
void rememberContextClassLoader() {
originalContextClassLoader = Thread.currentThread().getContextClassLoader();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe try looking at @ExtendWith(ClassLoadingIsolaterExtension.class) ? (I'd rather we try keeping those CL sort of tests using the same infra if possible 🤞🏻🙂)

Comment on lines +39 to +44
catch (JsonbException e) {
if ( e.getCause() instanceof ClassNotFoundException ) {
// The API is available, but its default provider is not.
return null;
}
throw e;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
catch (JsonbException e) {
if ( e.getCause() instanceof ClassNotFoundException ) {
// The API is available, but its default provider is not.
return null;
}
throw e;
catch (JsonbException e) {
log.debug(...,e);
return null;

the docs only seem to talk about JsonbException so maybe let's just log and move on ?

@github-actions

Copy link
Copy Markdown

Documentation Preview

Documentation preview artifact not found for commit 6f22f7e.
The documentation may not have changed, or the artifact may have expired.

View workflow run for details.

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants