Skip to content

ADFA-3467 | Fix IllegalStateException caused by missing IDEDebugClientImpl instance#1473

Open
jatezzz wants to merge 2 commits into
stagefrom
fix/ADFA-3467-debug-client-illegal-state-exception
Open

ADFA-3467 | Fix IllegalStateException caused by missing IDEDebugClientImpl instance#1473
jatezzz wants to merge 2 commits into
stagefrom
fix/ADFA-3467-debug-client-illegal-state-exception

Conversation

@jatezzz

@jatezzz jatezzz commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Description

This PR resolves an IllegalStateException: Cannot lookup IDEDebugClientImpl crash that occurs when invoking debugger actions (such as KillVmAction, StepOverAction, etc.) before the debugger client is initialized or after it has been disposed.

The debugClient property in AbstractDebuggerAction has been modified to be nullable (IDEDebugClientImpl?) and utilizes getInstance() instead of requireInstance(). Safe calls (?.) and explicit null checks have been introduced across all subclass actions to safely ignore or skip operations if the debugging instance is missing.

Details

java.lang.IllegalStateException: Cannot lookup IDEDebugClientImpl
    at com.itsaky.androidide.lsp.IDEDebugClientImpl$Companion.requireInstance(:11)
    at com.itsaky.androidide.actions.debug.KillVmAction.execAction(:2)

Before

Screen.Recording.2026-07-02.at.10.24.11.AM.mov

After

Screen.Recording.2026-07-03.at.10.15.07.AM.mov

Ticket

ADFA-3467

Observation

All debugger actions inheriting from AbstractDebuggerAction are now safe from throwing a termination exception if a user triggers shortcuts or interaction mechanisms while the VM is disconnected.

…eException

Avoid requiring an instance of IDEDebugClientImpl when it might not be initialized.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

@jatezzz

jatezzz commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator Author

@claude review once

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Code review skipped — your organization's overage spend limit has been reached.

Code review is billed via overage credits. To resume reviews, an organization admin can raise the monthly limit at claude.ai/admin-settings/claude-code.

Once credits are available, comment @claude review on this pull request to trigger a review.

@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3a562e03-182c-4a55-8725-ec6609b87b09

📥 Commits

Reviewing files that changed from the base of the PR and between bf89f5b and 69bc91a.

📒 Files selected for processing (7)
  • app/src/main/java/com/itsaky/androidide/actions/debug/AbstractDebuggerAction.kt
  • app/src/main/java/com/itsaky/androidide/actions/debug/AbstractStepAction.kt
  • app/src/main/java/com/itsaky/androidide/actions/debug/KillVmAction.kt
  • app/src/main/java/com/itsaky/androidide/actions/debug/StepIntoAction.kt
  • app/src/main/java/com/itsaky/androidide/actions/debug/StepOutAction.kt
  • app/src/main/java/com/itsaky/androidide/actions/debug/StepOverAction.kt
  • app/src/main/java/com/itsaky/androidide/actions/debug/SuspendResumeVmAction.kt

📝 Walkthrough
  • Fixed debugger action crashes by making IDEDebugClientImpl nullable in AbstractDebuggerAction and using getInstance() instead of requireInstance().
  • Updated debugger action enablement checks to handle a missing or disposed debug client safely, so actions are disabled when the VM/client is unavailable.
  • Guarded debugger commands (KillVm, StepInto, StepOut, StepOver, Suspend/Resume) with safe calls or early returns to avoid IllegalStateException/null dereference crashes.
  • Step-related actions now only run when the debugger is in an appropriate connection state, with null clients treated as disabled/inactive.
  • Risk: these actions now silently no-op when the debug client is unavailable, which can make failure conditions less visible to users and may require clearer UI feedback.

Walkthrough

Debugger action classes are modified to treat IDEDebugClientImpl as nullable, replacing requireInstance() with getInstance(). Enablement checks and execution methods (kill, step into/out/over, suspend/resume) now use null-safe calls or null guards to avoid crashes when no debug client is connected.

Changes

Nullable debug client handling

Layer / File(s) Summary
Base enablement checks
app/.../debug/AbstractDebuggerAction.kt, app/.../debug/AbstractStepAction.kt
debugClient becomes nullable via getInstance(); checkEnabled returns false when the client is null instead of assuming it exists.
Step and kill execution
app/.../debug/KillVmAction.kt, app/.../debug/StepIntoAction.kt, app/.../debug/StepOutAction.kt, app/.../debug/StepOverAction.kt
execAction methods use null-safe calls (debugClient?.killVm(), ?.stepInto(), ?.stepOut(), ?.stepOver()) so they no-op instead of crashing when debugClient is null.
Suspend/resume handling
app/.../debug/SuspendResumeVmAction.kt
prepare() uses a null-safe suspended check, and execAction() returns early if debugClient is null before deciding to resume or suspend.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • appdevforall/CodeOnTheGo#998: Both PRs address missing IDEDebugClientImpl by switching debugger actions to tolerate a null client instead of assuming it's always present.

Suggested reviewers: itsaky-adfa

Poem

A rabbit hops through debugger code,
Where null clients once caused a load,
Now safe-calls guard each little hop,
No crash, no bang, no sudden stop! 🐇
Step in, step out, resume with glee—
Null-safety sets the debugger free!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states the crash fix and the missing IDEDebugClientImpl instance, which matches the changes.
Description check ✅ Passed The description matches the code changes, describing the nullable debug client and null-safe debugger action handling.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/ADFA-3467-debug-client-illegal-state-exception

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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