File tree 2 files changed +1
-25
lines changed
main/java/org/apache/kafka/common/utils
test/java/org/apache/kafka/common/utils
2 files changed +1
-25
lines changed Original file line number Diff line number Diff line change @@ -94,14 +94,12 @@ public final class Utils {
94
94
95
95
private Utils () {}
96
96
97
- // This matches URIs of formats: host:port
97
+ // This matches URIs of formats: host:port and protocol://host:port
98
98
// IPv6 is supported with [ip] pattern
99
99
private static final Pattern HOST_PORT_PATTERN = Pattern .compile ("^(?:[0-9a-zA-Z\\ -%._]*://)?\\ [?([0-9a-zA-Z\\ -%._:]*)]?:([0-9]+)" );
100
100
101
101
private static final Pattern VALID_HOST_CHARACTERS = Pattern .compile ("([0-9a-zA-Z\\ -%._:]*)" );
102
102
103
- private static final Pattern PROTOCOL_PATTERN = Pattern .compile ("([A-Za-z0-9_]+)://" );
104
-
105
103
// Prints up to 2 decimal digits. Used for human-readable printing
106
104
private static final DecimalFormat TWO_DIGIT_FORMAT = new DecimalFormat ("0.##" ,
107
105
DecimalFormatSymbols .getInstance (Locale .ENGLISH ));
@@ -531,16 +529,6 @@ public static int murmur2(final byte[] data) {
531
529
return h ;
532
530
}
533
531
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
-
544
532
/**
545
533
* Extracts the hostname from a "host:port" address string.
546
534
* @param address address string to parse
Original file line number Diff line number Diff line change @@ -132,18 +132,6 @@ public void testGetHostValid(String protocol) {
132
132
assertEquals ("::1" , getHost ("[::1]:1234" ));
133
133
}
134
134
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
-
147
135
@ ParameterizedTest
148
136
@ CsvSource (value = {"PLAINTEXT" , "SASL_PLAINTEXT" , "SSL" , "SASL_SSL" })
149
137
public void testGetHostInvalid (String protocol ) {
You can’t perform that action at this time.
0 commit comments