Repository navigation
fix(parseq): add warning log on exception in withSafeSideEffect (#326) - #359
Open
reginaldalfret wants to merge 1 commit into
Open
reginaldalfret wants to merge 1 commit into
reginaldalfret wants to merge 1 commit into
Conversation
…edin#326) When an exception is thrown inside the task provider function or callable supplied to withSafeSideEffect, the exception was caught and converted into a failed task without any log entry. This made side effect failures difficult to diagnose and observe from the caller side. This fix: 1. Adds a warning log via LOGGER.warn before returning Task.failure in both instance and static variants of withSafeSideEffect. 2. Fixes missing whitespace in 'desc + " returned null"' for static withSafeSideEffect. 3. Adds regression tests validating that warning log events are generated with the expected description and exception class when side effect creation fails. Resolves linkedin#326 Signed-off-by: Reginald Alfret <reginaldalfret@gmail.com>
This branch has not been deployed
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
This PR addresses and resolves #326 (
Proper logging for withSafeSideEffect).Problem
In
Task.withSafeSideEffect(...), anyThrowablethrown during the evaluation of the task provider function (Function1) or callable (Callable) was caught and wrapped into aTask.failure(desc, t)without emitting any log message:Because
withSafeSideEffectis specifically designed to isolate side-effect failures and prevent them from failing the parent execution plan, exceptions thrown during task instantiation failed completely silently without trace in application logs. Callers had no straightforward way to diagnose or debug why a side effect was not created.Changes
LOGGER.warn("An exception was thrown while creating safe side effect task: " + desc, t);in both the instancewithSafeSideEffect(final String desc, final Function1<? super T, Task<?>> func)and staticwithSafeSideEffect(final String desc, final Callable<Task<T>> func)methods before returningTask.failure(desc, t).withSafeSideEffect:"returned null"->" returned null", matching instancewithSafeSideEffect.testWithSafeSideEffectFailureInTaskProviderFunctionandtestStaticWithSafeSideEffectFailureInTaskProviderFunctioninAbstractTaskTest.javato attach aTestLogAppenderand assert that aWARNlevel log entry is emitted with the corresponding side-effect description and exception type.Validation
:parseq:test --tests "com.linkedin.parseq.TestTask": 47 passed, 0 failures, 0 errors, 1 skipped (historical).Fixes #326.
Signed-off-by: Reginald Alfret reginaldalfret@gmail.com