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

   Fixes #13620
   Fixes #16444
   Fixes #16427
   
   ### Motivation
   
   Mockito is not thread safe and there's a problem with mocking PulsarService 
which is described in #16821 description:
   > I found the cause of the problem: while executing 
doReturn(pulsarResources).when(pulsar).getPulsarResources(), Meta Store Thread 
also accesses variable PulsarService.getPulsarResources() asynchronously in 
logic: notification by zk-watcher(Concurrent access will be problematic if the 
object is being mock bound).
   
   Unfortunately, the solution made in PR #16821 didn't fix the problem. A 
better solution is needed to fix the problem.
   
   ### Modifications
   
   Replace the Mockito spy based PulsarService used in a few unit tests with a 
subclass of PulsarService which reduces the use of Mockito. Mockito spies can 
be continued to be used, but the getters are replaced with overridden methods 
in a new class TestPulsarService which extends PulsarService.
   The test code is also simplified by moving the required collaborator objects 
and resources to the TestPulsarService.Factory class which contains a `close()` 
method to close and release the allocated resources.
   
   ### Documentation
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   - [ ] `doc` <!-- Your PR contains doc changes. Please attach the local 
preview screenshots (run `sh start.sh` at `pulsar/site2/website`) to your PR 
description, or else your PR might not get merged. -->
   - [ ] `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