Skip to content

Eager TLS resolution to avoid CDI lookups on worker threads#421

Merged
kjeldpaw merged 1 commit intoquarkiverse:mainfrom
Saphri:tlscontext-on-main
Feb 5, 2026
Merged

Eager TLS resolution to avoid CDI lookups on worker threads#421
kjeldpaw merged 1 commit intoquarkiverse:mainfrom
Saphri:tlscontext-on-main

Conversation

@Saphri
Copy link
Contributor

@Saphri Saphri commented Feb 4, 2026

Fixes #411

Summary

Eagerly resolve and cache the TLS configuration (SSLContext) during CDI initialization to prevent CDI lookups from Vert.x worker threads that can cause first-attempt NATS connection failures.

Changes

  • TlsContextFactoryImpl — resolve and cache TlsContext in @PostConstruct, return cached instance from the producer
  • ConnectionFactoryImpl — force TLS resolution during bean initialization (@PostConstruct) to ensure TLS is available before worker-thread operations

Result

Prevents intermittent java.io.IOException: Unable to connect to NATS servers on the first connection attempt by avoiding CDI registry access from worker threads.

Notes

  • Behavior is now fail-fast at CDI startup for TLS misconfiguration.

@Saphri Saphri requested a review from a team as a code owner February 4, 2026 20:58
@Saphri Saphri closed this Feb 4, 2026
@Saphri Saphri reopened this Feb 4, 2026
@Saphri Saphri changed the title Add @PostConstruct initialization for TLS context in ConnectionFactor… Eager TLS resolution to avoid CDI lookups on worker threads Feb 4, 2026
@kjeldpaw kjeldpaw merged commit d80545e into quarkiverse:main Feb 5, 2026
4 of 5 checks passed
@Saphri Saphri deleted the tlscontext-on-main branch February 5, 2026 08:38
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.

CDI context not available when accessing TlsConfigurationRegistry from Vert.x worker thread

2 participants