Uploaded image for project: 'Hadoop HDFS'
  1. Hadoop HDFS
  2. HDFS-16932

Mockito causing ClassCastException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 3.4.0
    • None
    • hdfs
    • None
    • Running in the Hadoop development environment in docker, running mvn.

    Description

      Running tests in TestBalancerRPCDelay fails because of ClassCastExceptions introduced by Mockito.  As an example, in this stack trace note that the RedundancyMonitor is calling "isRunning" but incorrectly ends up being routed to getBlocks (which returns BlocksWithLocations) via TestBalancer and a Mockito Spy.  This ultimately is reported as a failure during the shutdown process.

      Exception in thread "RedundancyMonitor" java.lang.ClassCastException: java.lang.Boolean cannot be cast to org.apache.hadoop.hdfs.server.protocol.BlocksWithLocations        at org.apache.hadoop.hdfs.server.balancer.TestBalancer$2.answer(TestBalancer.java:1865)        at org.apache.hadoop.hdfs.server.balancer.TestBalancer$2.answer(TestBalancer.java:1858)        at org.mockito.internal.stubbing.StubbedInvocationMatcher.answer(StubbedInvocationMatcher.java:39)        at org.mockito.internal.handler.MockHandlerImpl.handle(MockHandlerImpl.java:96)        at org.mockito.internal.handler.NullResultGuardian.handle(NullResultGuardian.java:29)        at org.mockito.internal.handler.InvocationNotifierHandler.handle(InvocationNotifierHandler.java:35)        at org.mockito.internal.creation.bytebuddy.MockMethodInterceptor.doIntercept(MockMethodInterceptor.java:61)        at org.mockito.internal.creation.bytebuddy.MockMethodInterceptor.doIntercept(MockMethodInterceptor.java:49)        at org.mockito.internal.creation.bytebuddy.MockMethodInterceptor$DispatcherDefaultingToRealMethod.interceptSuperCallable(MockMethodInterceptor.java:108)        at org.apache.hadoop.hdfs.server.namenode.FSNamesystem$MockitoMock$1070381809.isRunning(Unknown Source)        at org.apache.hadoop.hdfs.server.blockmanagement.BlockManager$RedundancyMonitor.run(BlockManager.java:5155)        at java.lang.Thread.run(Thread.java:750)

      Attachments

        Activity

          People

            Unassigned Unassigned
            svaughan Steve Vaughan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: