@@ -352,6 +352,51 @@ class ShuffleBlockFetcherIteratorSuite extends SparkFunSuite with PrivateMethodT
352352 intercept[FetchFailedException ] { iterator.next() }
353353 }
354354
355+ test(" big blocks are not checked for corruption" ) {
356+ val corruptStream = mock(classOf [InputStream ])
357+ when(corruptStream.read(any(), any(), any())).thenThrow(new IOException (" corrupt" ))
358+ val corruptBuffer = mock(classOf [ManagedBuffer ])
359+ when(corruptBuffer.createInputStream()).thenReturn(corruptStream)
360+ doReturn(10000L ).when(corruptBuffer).size()
361+
362+ val blockManager = mock(classOf [BlockManager ])
363+ val localBmId = BlockManagerId (" test-client" , " test-client" , 1 )
364+ doReturn(localBmId).when(blockManager).blockManagerId
365+ doReturn(corruptBuffer).when(blockManager).getBlockData(ShuffleBlockId (0 , 0 , 0 ))
366+ val localBlockLengths = Seq [Tuple2 [BlockId , Long ]](
367+ ShuffleBlockId (0 , 0 , 0 ) -> corruptBuffer.size()
368+ )
369+
370+ val remoteBmId = BlockManagerId (" test-client-1" , " test-client-1" , 2 )
371+ val remoteBlockLengths = Seq [Tuple2 [BlockId , Long ]](
372+ ShuffleBlockId (0 , 1 , 0 ) -> corruptBuffer.size()
373+ )
374+
375+ val transfer = createMockTransfer(
376+ Map (ShuffleBlockId (0 , 0 , 0 ) -> corruptBuffer, ShuffleBlockId (0 , 1 , 0 ) -> corruptBuffer))
377+
378+ val blocksByAddress = Seq [(BlockManagerId , Seq [(BlockId , Long )])](
379+ (localBmId, localBlockLengths),
380+ (remoteBmId, remoteBlockLengths)
381+ )
382+
383+ val taskContext = TaskContext .empty()
384+ val iterator = new ShuffleBlockFetcherIterator (
385+ taskContext,
386+ transfer,
387+ blockManager,
388+ blocksByAddress,
389+ (_, in) => new LimitedInputStream (in, 10000 ),
390+ 2048 ,
391+ Int .MaxValue ,
392+ Int .MaxValue ,
393+ Int .MaxValue ,
394+ true )
395+ // Blocks should be returned without exceptions.
396+ assert(Set (iterator.next()._1, iterator.next()._1) ===
397+ Set (ShuffleBlockId (0 , 0 , 0 ), ShuffleBlockId (0 , 1 , 0 )))
398+ }
399+
355400 test(" retry corrupt blocks (disabled)" ) {
356401 val blockManager = mock(classOf [BlockManager ])
357402 val localBmId = BlockManagerId (" test-client" , " test-client" , 1 )
0 commit comments