Use common classloader for all RTI factory calls - #101
Open
isaiahhaensel wants to merge 2 commits into
Open
Conversation
Adds a custom implementation of RtiFactoryFactory that ensures that all factory loading attempts use the same classloader, specifically the one that has been extended with the RTI HLA jar paths.
isaiahhaensel
marked this pull request as ready for review
July 27, 2026 06:03
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.
In HLA mode (RPR connection), Disco relies on extending the classpath with RTI provider libraries and uses an implementation of
RtiFactoryFactorywhich employs the current thread's context class loader.This currently contributes to two issues:
Only the context class loader of the thread that calls
OpsCenter#openbenefits from the classpath extension, so any calls toRtiFactoryFactory#getRtiFactoryfrom other threads (e.g., worker threads callingFederateAmbassador#receiveInteraction) may fail.RTI providers (e.g., MAK) may use native libraries that cannot be loaded in more than one classloader. This means that if
DisApplication#startis initially called from one thread, then later from another thread, the second call will fail onRprConnection#initializeFederation's call toRtiFactoryFactory#getRtiFactory. See below for an example error when using the MAK RTI.A simple way to resolve this is to ensure that all
RtiFactoryloading attempts use the same classloader. This PR achieves this by adding a newRprRtiFactoryFactoryclass which caches the classloader on the first call and re-uses it for all subsequent calls.Additionally, and only indirectly related, this PR adds a check to avoid calling
RtiAmbassador#destroyFederationExecutionwhen disconnecting from a MAK RTI federation, because (at least currently) that call frequently either hangs, crashes the application, or crashes the JVM with anEXCEPTION_ACCESS_VIOLATIONatlibrti1516eJava64.dll+0xc0525. The MAK RTI is designed to clean up the federation execution on disconnect anyway, making the call effectively redundant.