CapMoon opened a new pull request, #8393:
URL: https://github.com/apache/hadoop/pull/8393

   HDFS-17902. StripedBlockChecksumReconstructor leaks connections on init 
failure
   
   ### Description of PR
   When BlockGroupNonStripedChecksumComputer.recalculateChecksum() allocates a 
StripedBlockChecksumReconstructor with try-with-resources, the reconstructor's 
constructor calls StripedReconstructor's superclass constructor first, which 
creates a StripedReader. The constructor then calls getStripedReader().init(), 
which in turn calls initReaders().
   
   If initReaders() fails because nSuccess < minRequiredSources, it throws 
IOException. initReaders() does not close StripedBlockReader instances that 
were already created and may already hold open block/TCP connections to peer 
DataNodes.
   
   Because the constructor throws before the StripedBlockChecksumReconstructor 
instance is successfully created, the try-with-resources statement never 
assigns the resource variable and therefore does not invoke Closeable.close() 
on the reconstructor (JLS: resource is only closed if initialization completes 
normally). As a result, StripedReader.close() is never called on that code 
path, and connections opened during the failed initReaders() loop can leak.
   
   By contrast, StripedBlockReconstructor.run() always calls 
getStripedReader().close() in a finally block, so the same failure mode is 
cleaned up there.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to