@@ -27,14 +27,15 @@ import org.mockito.Matchers.{any, eq => meq}
2727import org .mockito .Mockito ._
2828import org .mockito .invocation .InvocationOnMock
2929import org .mockito .stubbing .Answer
30+ import org .scalatest .PrivateMethodTester
3031
3132import org .apache .spark .{SparkFunSuite , TaskContextImpl }
3233import org .apache .spark .network ._
3334import org .apache .spark .network .buffer .ManagedBuffer
3435import org .apache .spark .network .shuffle .BlockFetchingListener
3536
3637
37- class ShuffleBlockFetcherIteratorSuite extends SparkFunSuite {
38+ class ShuffleBlockFetcherIteratorSuite extends SparkFunSuite with PrivateMethodTester {
3839 // Some of the tests are quite tricky because we are testing the cleanup behavior
3940 // in the presence of faults.
4041
@@ -113,13 +114,15 @@ class ShuffleBlockFetcherIteratorSuite extends SparkFunSuite {
113114 // Note: ShuffleBlockFetcherIterator wraps input streams in a BufferReleasingInputStream
114115 val wrappedInputStream = inputStream.get.asInstanceOf [BufferReleasingInputStream ]
115116 verify(mockBuf, times(0 )).release()
116- verify(wrappedInputStream.delegate, times(0 )).close()
117+ val delegateAccess = PrivateMethod [InputStream ](' delegate )
118+
119+ verify(wrappedInputStream.invokePrivate(delegateAccess()), times(0 )).close()
117120 wrappedInputStream.close()
118121 verify(mockBuf, times(1 )).release()
119- verify(wrappedInputStream.delegate , times(1 )).close()
122+ verify(wrappedInputStream.invokePrivate(delegateAccess()) , times(1 )).close()
120123 wrappedInputStream.close() // close should be idempotent
121124 verify(mockBuf, times(1 )).release()
122- verify(wrappedInputStream.delegate , times(1 )).close()
125+ verify(wrappedInputStream.invokePrivate(delegateAccess()) , times(1 )).close()
123126 }
124127
125128 // 3 local blocks, and 2 remote blocks
0 commit comments