UncaughtHandler.uninstall() removes another adapter's handler · Issue #262 · stacktale/stacktale · GitHub
Skip to content

UncaughtHandler.uninstall() removes another adapter's handler #262

Open

Description

@GabrielBBaldez

UncaughtHandler.uninstall() restores previous whenever the current default handler is any UncaughtHandler, not the caller's own:

if (Thread.getDefaultUncaughtExceptionHandler() instanceof UncaughtHandler ours) {
    Thread.setDefaultUncaughtExceptionHandler(ours.previous);
}

If adapter A installs, then adapter B installs, and then A stops, B's handler is removed while B is still running, so uncaught exceptions stop being reported. This only happens when two adapters' lifetimes overlap. A plain stop-then-start is fine.

Fix direction: uninstall removes only the handler that the caller installed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions