fix: don't load session_util from ProStatusManager class init - #2154
Closed
Bilb wants to merge 1 commit into
Closed
Conversation
The companion `val`s reading SessionProtocol.PRO_HIGHER_CHARACTER_LIMIT /
STANDARD_CHARACTER_LIMIT were compiled into ProStatusManager.<clinit>.
SessionProtocol is an object extending LibSessionUtilCApi, whose constructor
calls System.loadLibrary("session_util"), so merely class-loading
ProStatusManager pulled in the native library. There is no session_util on the
JVM, which broke `testPlayDebugUnitTest` on dev: mock<ProStatusManager>() in
ConversationViewModelTest.createViewModel failed with
UnsatisfiedLinkError: no session_util in java.library.path
and the 8 following tests died with NoClassDefFoundError (9 failures total).
Read both limits through getters instead, keeping class init free of native
side effects. SessionProtocol already caches them via `by lazy`, so each call
site is still a field read, and the values are only fetched when a real
ProStatusManager needs them.
Collaborator
Author
|
Closing as https://github.com/session-foundation/session-android/pull/2153/changes already have the same fix |
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.
Problem
testPlayDebugUnitTesthas been failing ondevsince c203de9 ("Native codepoint counting; route char-limit policy through libsession") — 9ConversationViewModelTestfailures. Every PR branched offdevinherits it (e.g. #2137, which only bumpsactions/cache).From the
test-reportsartifact (the console log only shows the truncatedExceptionInInitializerError):SessionProtocolis a KotlinobjectextendingLibSessionUtilCApi, whose constructor callsSystem.loadLibrary("session_util"). Because the char limits were read into companionvals, they were compiled intoProStatusManager.<clinit>— so merely class-loadingProStatusManagerloaded the native library. There is nosession_utilon the JVM, somock<ProStatusManager>()inConversationViewModelTest.createViewModelblew up and the 8 subsequent tests followed withNoClassDefFoundError.Fix
Read both limits through getters instead of storing them in the initialiser, keeping class init free of native side effects.
SessionProtocolalready caches both values viaby lazy, so each call site is still a field read, and the values are only fetched when a realProStatusManagerneeds them.Both are only used from instance methods (
getIncomingMessageMaxLength,getCharacterLimit) and nowhere outside the file, so no callers change.Verification
./gradlew testPlayDebugUnitTestlocally: 198 tests, 0 failures (was198 tests completed, 9 failedin CI).