apoorvmittal10 commented on code in PR #17519:
URL: https://github.com/apache/kafka/pull/17519#discussion_r1809325469


##########
clients/src/main/java/org/apache/kafka/common/network/ServerConnectionId.java:
##########
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kafka.common.network;
+
+import java.net.Socket;
+import java.util.Map;
+import java.util.Optional;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * ServerConnectionId is used to uniquely identify a connection on server for 
the client. The
+ *  connection id is in the format of 
"localHost:localPort-remoteHost:remotePort-processorId-index".
+ *  The processorId is the id of the processor that will handle this 
connection and the index is
+ *  used to ensure uniqueness.
+ */
+public class ServerConnectionId {
+
+    private static final Pattern URI_PARSE_EXP = 
Pattern.compile("\\[?([0-9a-zA-Z\\-%._:]*)]?:([0-9]+)");

Review Comment:
   > Utils.HOST_PORT_PATTERN is more general than this. We could just reuse the 
former instead.
   
   I initially looked at it but didn't use that as it also has `protocol` 
parsing which we don't require. And moreover I thought to port same scala 
version to java.
   
   > This means that when we try to convert the connection string back to 
ConnectionId, we can't parse the hostname properly if it's IPV6. To fix this, 
it seems that we need to add brackets to the hostname when generating the 
connection string.
   
   I don't think it's a bug, I am writing a test case for same as well. The 
regex splits on the end `:` hence the host and port will be constructed 
correctly.



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