GH-3346 Fix RedisPipelineException double-wrapping in LettuceConnection.closePipeline().#3347
Open
JEONGJAEIK wants to merge 1 commit intospring-projects:mainfrom
Open
Conversation
…Pipeline(). The catch (Exception ex) block in closePipeline() was too broad, catching intentionally thrown RedisPipelineExceptions and re-wrapping them with the misleading default message "Pipeline contained one or more invalid commands". Introduce a dedicated catch (RedisPipelineException ex) block to propagate the original exception directly. Closes spring-projects#3346 Signed-off-by: JEONGJAEIK <wodlr1207@naver.com>
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.
Bug Description
LettuceConnection.closePipeline()wraps all exceptions in a genericRedisPipelineExceptionwith the misleading message "Pipeline contained one or more invalid commands", even when the actual cause is a timeout or a failed Redis command.Root Cause
The
try-catchblock inclosePipeline()is too broad. Both intentionalRedisPipelineExceptionthrows (lines 646 and 653) are caught by the samecatch (Exception ex)block, causing them to be wrapped again in a newRedisPipelineException.Impact
A timeout (awaitAll returns false) surfaces as:
RedisPipelineException("Pipeline contained one or more invalid commands", cause=RedisPipelineException(cause=QueryTimeoutException)) instead of: RedisPipelineException(cause=QueryTimeoutException)
A failed command surfaces with the same misleading message and an extra layer of wrapping, making it impossible to distinguish a timeout from an actual invalid command via getCause().
Expected Behavior
RedisPipelineException thrown intentionally inside closePipeline() should propagate directly without re-wrapping.
Fix
} catch (RedisPipelineException ex) {
throw ex;
} catch (Exception ex) {
throw new RedisPipelineException(ex);
}
Addendum
The default message
"Pipeline contained one or more invalid commands"is hardcoded in theRedisPipelineException(Exception cause)constructor.This message is misleading when the actual cause is a timeout rather than an invalid command. Whether this message should also be improved is left for further discussion.
Closes #3346