Skip to content

Commit cc57aff

Browse files
committed
Revert "Parse protocol"
This reverts commit 906a4d7.
1 parent 449aa5f commit cc57aff

File tree

2 files changed

+1
-25
lines changed

2 files changed

+1
-25
lines changed

clients/src/main/java/org/apache/kafka/common/utils/Utils.java

+1-13
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,12 @@ public final class Utils {
9494

9595
private Utils() {}
9696

97-
// This matches URIs of formats: host:port
97+
// This matches URIs of formats: host:port and protocol://host:port
9898
// IPv6 is supported with [ip] pattern
9999
private static final Pattern HOST_PORT_PATTERN = Pattern.compile("^(?:[0-9a-zA-Z\\-%._]*://)?\\[?([0-9a-zA-Z\\-%._:]*)]?:([0-9]+)");
100100

101101
private static final Pattern VALID_HOST_CHARACTERS = Pattern.compile("([0-9a-zA-Z\\-%._:]*)");
102102

103-
private static final Pattern PROTOCOL_PATTERN = Pattern.compile("([A-Za-z0-9_]+)://");
104-
105103
// Prints up to 2 decimal digits. Used for human-readable printing
106104
private static final DecimalFormat TWO_DIGIT_FORMAT = new DecimalFormat("0.##",
107105
DecimalFormatSymbols.getInstance(Locale.ENGLISH));
@@ -531,16 +529,6 @@ public static int murmur2(final byte[] data) {
531529
return h;
532530
}
533531

534-
/**
535-
* Extracts the protocol from a "protocol://host:port" address string.
536-
* @param address address string to parse
537-
* @return hostname or null if the given address is incorrect
538-
*/
539-
public static String getProtocol(String address) {
540-
Matcher matcher = PROTOCOL_PATTERN.matcher(address);
541-
return matcher.lookingAt() ? matcher.group(1) : null;
542-
}
543-
544532
/**
545533
* Extracts the hostname from a "host:port" address string.
546534
* @param address address string to parse

clients/src/test/java/org/apache/kafka/common/utils/UtilsTest.java

-12
Original file line numberDiff line numberDiff line change
@@ -132,18 +132,6 @@ public void testGetHostValid(String protocol) {
132132
assertEquals("::1", getHost("[::1]:1234"));
133133
}
134134

135-
@ParameterizedTest
136-
@CsvSource(value = {"PLAINTEXT", "SASL_PLAINTEXT", "SSL", "SASL_SSL"})
137-
public void testGetProtocol(String protocol) {
138-
assertEquals(protocol, getProtocol(protocol + "://mydomain.com:8080"));
139-
assertEquals(protocol, getProtocol(protocol + "://MyDomain.com:8080"));
140-
assertEquals(protocol, getProtocol(protocol + "://My_Domain.com:8080"));
141-
assertEquals(protocol, getProtocol(protocol + "://[::1]:1234"));
142-
assertEquals(protocol, getProtocol(protocol + "://[2001:db8:85a3:8d3:1319:8a2e:370:7348]:5678"));
143-
assertEquals(protocol, getProtocol(protocol + "://[2001:DB8:85A3:8D3:1319:8A2E:370:7348]:5678"));
144-
assertEquals(protocol, getProtocol(protocol + "://[fe80::b1da:69ca:57f7:63d8%3]:5678"));
145-
}
146-
147135
@ParameterizedTest
148136
@CsvSource(value = {"PLAINTEXT", "SASL_PLAINTEXT", "SSL", "SASL_SSL"})
149137
public void testGetHostInvalid(String protocol) {

0 commit comments

Comments
 (0)