rdhabalia commented on a change in pull request #9967:
URL: https://github.com/apache/pulsar/pull/9967#discussion_r597451329



##########
File path: 
pulsar-discovery-service/src/test/java/org/apache/pulsar/discovery/service/web/DiscoveryServiceWebTest.java
##########
@@ -78,10 +80,14 @@
  */
 public class DiscoveryServiceWebTest extends BaseZKStarterTest{
 
+    private static final Logger log = 
LoggerFactory.getLogger(DiscoveryServiceWebTest.class);
+
     private Client client = ClientBuilder.newClient(new 
ClientConfig().register(LoggingFeature.class));
     private static final String TLS_SERVER_CERT_FILE_PATH = 
"./src/test/resources/certificate/server.crt";
     private static final String TLS_SERVER_KEY_FILE_PATH = 
"./src/test/resources/certificate/server.key";
-
+    // DiscoveryServiceServlet gets initialized by a server and this map will 
help to retrieve ZK while mocking
+    // DiscoveryServiceServlet
+    private static final Map<String, MetadataStoreExtended> 
metadataStoreInstanceCache = Maps.newConcurrentMap();

Review comment:
       It's not leaking. static map is intentional because of the 
`DiscoveryServiceServlet` which gets initialized by Webserver and we need to 
inject MetadataStore into dynamically initialized servelet. so, 
`DiscoveryServiceServletTest`  extends the discovery-servlet class and access 
metadata store from this static map.
   It's not leaking because everytime when test starts it puts the 
metadatastore into the map and then it closes the metadata store at the end of 
test so, it will not leak. 
   So, static map is the way to access metadata-store from dynamically 
initialized servlet which we can't be mocked or controlled.




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to