Marcosrico commented on code in PR #2550:
URL: https://github.com/apache/helix/pull/2550#discussion_r1248295224


##########
meta-client/src/main/java/org/apache/helix/metaclient/recipes/lock/DistributedSemaphore.java:
##########
@@ -75,9 +76,12 @@ public DistributedSemaphore(MetaClientInterface<DataRecord> 
client) {
     _metaClient = client;
     try {
       _metaClient.connect();
-      // TODO: Differentiate exception catch between already connected and 
already closed.
     } catch (IllegalStateException e) {
-      // Ignore as it either has already been connected or already been closed.
+      if (e.getMessage().contains("connect() has already been called")) {
+        LOG.info("Client already connected");

Review Comment:
   Right but there is no other way as far as I know. There is a method that 
checks whether a node is closed but that is zk specific and shouldn't be added 
in a generic distributedSemaphore client creation. Zk.connect() throws the same 
IllegalStateException for both client exceptions so there isn't a way of 
separating the two. Furthermore, while kinda of hacky, the current 
implementation of zkClient.connect() exceptions is very mature and the chances 
of one modifying it is slim. However, this begs the question for future use 
cases besides zk.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to