Repository navigation
ADFA-5363: Initialize Termux properties when TermuxService is created first - #2128
Open
Daniel-ADFA wants to merge 1 commit into
Open
Daniel-ADFA wants to merge 1 commit into
Daniel-ADFA wants to merge 1 commit into
Conversation
… first TermuxService.onCreate() copied TermuxAppSharedProperties.getProperties() into mProperties. The singleton is created by TermuxApplicationLoader, which runs asynchronously after the process starts, so a service created before it kept a null mProperties and the first createTermuxSession() threw a NullPointerException (GlitchTip CODEONTHEGO-7G, up to C-r-1006). Use init(), which returns the loaded instance or loads it, as onCreate() already does for TermuxShellManager (ADFA-4330). init() is now synchronized and the field volatile, because the service and the startup loader can both call it during startup and must share one instance.
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.
Tip: disable this comment in your organization's Code Review settings.
Contributor
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.
ADFA-5363
Fixes the fatal
NullPointerExceptioninTermuxService.createTermuxSession()(GlitchTip CODEONTHEGO-7G, 18 events, still on C-r-1006).TermuxService.onCreate()gets the properties withTermuxAppSharedProperties.init()instead ofgetProperties(). When the service is created before the asyncTermuxApplicationLoaderhas run,getProperties()wasnulland stayednullinmProperties. Same fix ADFA-4330 made forTermuxShellManagertwo lines below.TermuxAppSharedProperties.init()issynchronizedand the fieldvolatile, since the service and the loader can now both call it at startup.TermuxServicePropertiesNpeTestfails without the fix.Other
getProperties()readers:TermuxShellUtils.clearTermuxTMPDIR()is only called fromTermuxService.onDestroy(), covered here;TermuxPluginUtilsnull-checks;TermuxAmSocketServerandFileReceiverActivityrun after aninit().Reproduce (debug build, jdb)
adb forward tcp:8700 jdwp:$(adb shell pidof com.itsaky.androidide)andjdb -attach localhost:8700stop in com.termux.app.TermuxService.onCreate, then open the Terminal from the drawer.set com.termux.shared.termux.settings.properties.TermuxAppSharedProperties.properties = null,clear com.termux.app.TermuxService.onCreate,cont.