When a primary datanode tries to recover a block. It calls getBlockMetaDataInfo(..) to obtains information like block length from each datanode. Then, it calls updateBlock(..).
The block length returned in getBlockMetaDataInfo(..) may be obtained from a unclosed local block file F. However, in updateBlock(..), it first closes F (if F is open) and then gets the length. These two lengths may be different. In such case, updateBlock(..) throws an exception.