HDFS-17879. Premature error handling accesses uninitialized dnInfo.#8281
Open
balodesecurity wants to merge 1 commit intoapache:trunkfrom
Open
HDFS-17879. Premature error handling accesses uninitialized dnInfo.#8281balodesecurity wants to merge 1 commit intoapache:trunkfrom
balodesecurity wants to merge 1 commit intoapache:trunkfrom
Conversation
In DFSStripedInputStream.createBlockReader(), dnInfo is initialized with all-null fields before the loop, then populated by getBestNodeDNAddrPair(). If refreshLocatedBlock() throws an IOException before getBestNodeDNAddrPair() is called, the catch block accessed dnInfo.addr (still null), causing a NullPointerException that masked the original error. Fix: add a null check on dnInfo.addr at the top of the catch block. If null, the exception occurred before any DataNode was identified, so we rethrow the original IOException directly. Added TestDFSStripedInputStream#testCreateBlockReaderExceptionBeforeDnInfoInit to verify the IOException is propagated cleanly without NPE. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.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.
Description of PR
JIRA: https://issues.apache.org/jira/browse/HDFS-17879
Problem
In
DFSStripedInputStream.createBlockReader(),dnInfois initialized with all-null fields before the retry loop:It is then populated by
getBestNodeDNAddrPair()— but only afterrefreshLocatedBlock()is called first. IfrefreshLocatedBlock()throws anIOException, the catch block immediately accessesdnInfo.addr(stillnull), causing aNullPointerExceptionthat masks the original error:Fix
Add a null check on
dnInfo.addrat the top of the catch block. Ifnull, the failure occurred before any DataNode was identified, so we rethrow the originalIOExceptiondirectly — preserving the real error for the caller.Testing
Added
TestDFSStripedInputStream#testCreateBlockReaderExceptionBeforeDnInfoInitwhich uses Mockito to makerefreshLocatedBlock()throw anIOException, and verifies:NullPointerExceptionis thrown (masked error)IOExceptionis propagated cleanlyFor code changes:
LICENSE,LICENSE-binary,NOTICE-binaryfiles?