Use try/catch for non-blocking Java calls and log Cause#113
Closed
EtaCassiopeia wants to merge 1 commit into
Closed
Use try/catch for non-blocking Java calls and log Cause#113EtaCassiopeia wants to merge 1 commit into
EtaCassiopeia wants to merge 1 commit into
Conversation
Owner
Author
|
Tested independently; closing in favor of #110. |
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.
Summary
getProviderHooksandwrapJavaHook.beforewere wrapping Java SDK calls inZIO.attempt(...).catchAll(...).ZIO.attemptcreates aSyncnode andcatchAlladds aFlatMapnode — two ZIO instances the runloop must interpret. Since the wrapped calls are non-blocking, in-memory Java methods, a plaintry/catch+Exit.succeed(orZIO.succeed { try { ... } catch ... }) achieves the same safety with fewer runloop iterations.Also upgrades
getProviderHookserror logging fromZIO.logWarning(s"... ${e.getMessage}")toZIO.logWarningCause(...)so the fullCause(with stack trace) appears in diagnostics.Changes
FeatureFlagsLive.getProviderHooks—ZIO.attempt + catchAll→try/catch + Exit.succeed; logCause.fail(e)instead of just the messageFeatureFlagsLive.wrapJavaHook.before—ZIO.attempt + catchAll(_ => ZIO.none)→ZIO.succeed { try { ... } catch { case NonFatal(_) => None } }Both call sites assume
NonFatal(preserves originalException-catching behavior;VirtualMachineError/LinkageErrorpropagate).Credit
Spotted in #110 by @guizmaii. The
logWarningCauseupgrade is an addition; the original PR kept the message-only logging.