mohitduhan19 commented on code in PR #4504: URL: https://github.com/apache/iggy/pull/4504#discussion_r4256961568
########## foreign/java/java-sdk/src/main/java/org/apache/iggy/builder/TcpConnectionString.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.iggy.builder; + +import org.apache.iggy.exception.IggyInvalidArgumentException; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * A parsed {@code iggy://} connection string for the TCP transport. + * + * <p>Follows {@code parseConnectionString} in the Node SDK, limited to what the Java + * TCP builders support: {@code username:password} credentials and the {@code tls} option. + * Error messages never include the connection string, because it contains the password. + */ +record TcpConnectionString(String host, int port, String username, String password, boolean tls) { + + private static final String DEFAULT_SCHEME = "iggy"; + private static final String SCHEME_PREFIX = "iggy+"; + private static final String TCP_TRANSPORT = "tcp"; + private static final int MAX_PORT = 65535; + + // Matches both "[ipv6]:port" and "host:port", where an unbracketed host may not + // contain a colon. Multi-colon authorities such as "2001:db8::1:8090" are rejected. + private static final Pattern ADDRESS = Pattern.compile("^(?:\\[([^\\]]+)\\]|([^:\\[\\]]+)):(\\d{1,5})$"); Review Comment: Fixed in 3e37a02. Both host alternatives now exclude whitespace and control characters (`\s` and `\p{Cc}`), like the C# pattern. In e86abf0 I added test cases for a host with a space, one with a tab, and a bracketed IPv6 host with a space. -- 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]
