lhotari opened a new pull request, #24165:
URL: https://github.com/apache/pulsar/pull/24165

   ### Motivation
   
   [Mockito is not thread 
safe](https://github.com/mockito/mockito/wiki/FAQ#is-mockito-thread-safe) and 
modifying mocks in multi-threaded code will result in failures such as this one:
   
   ```
      [ERROR] Failures:
       [ERROR]   
NamespaceAuthZTest.testMaxConsumersPerTopic:1537->setAuthorizationPolicyOperationChecker:183
 ยป UnfinishedStubbing
       Unfinished stubbing detected here:
       -> at 
org.apache.pulsar.broker.admin.NamespaceAuthZTest.setAuthorizationPolicyOperationChecker(NamespaceAuthZTest.java:173)
   
       E.g. thenReturn() may be missing.
       Examples of correct stubbing:
           when(mock.isOk()).thenReturn(true);
           when(mock.isOk()).thenThrow(exception);
           doThrow(exception).when(mock).someVoidMethod();
       Hints:
        1. missing thenReturn()
        2. you are trying to stub a final method, which is not supported
        3. you are stubbing the behaviour of another mock inside before 
'thenReturn' instruction is completed
   ```
   
   ### Modifications
   
   - refactor the test code to setup the mock once and switch the 
implementation dynamically
   
   ### Documentation
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   - [ ] `doc` <!-- Your PR contains doc changes. -->
   - [ ] `doc-required` <!-- Your PR changes impact docs and you will update 
later -->
   - [x] `doc-not-needed` <!-- Your PR changes do not impact docs -->
   - [ ] `doc-complete` <!-- Docs have been already added -->


-- 
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]

Reply via email to