-
Notifications
You must be signed in to change notification settings - Fork 14.3k
KAFKA-18760: Deprecate Optional<String> and return String from public Endpoint#listener #19191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Changes from 9 commits
5a57f0b
a6497b7
5761989
22b1848
ae2abed
a54b7ca
7dde246
14c1139
e2ca968
3eb16c8
48103d9
07eff76
0306ca1
bbf483b
403d00c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,35 +16,51 @@ | |
*/ | ||
package org.apache.kafka.common; | ||
|
||
import org.apache.kafka.common.annotation.InterfaceStability; | ||
import org.apache.kafka.common.security.auth.SecurityProtocol; | ||
|
||
import java.util.Locale; | ||
import java.util.Objects; | ||
import java.util.Optional; | ||
|
||
/** | ||
* Represents a broker endpoint. | ||
*/ | ||
|
||
@InterfaceStability.Evolving | ||
public class Endpoint { | ||
|
||
private final String listenerName; | ||
private final SecurityProtocol securityProtocol; | ||
private final String host; | ||
private final int port; | ||
|
||
public static String parseListenerName(String connectionString) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it seems only |
||
int firstColon = connectionString.indexOf(':'); | ||
if (firstColon < 0) { | ||
throw new KafkaException("Unable to parse a listener name from " + connectionString); | ||
} | ||
return connectionString.substring(0, firstColon).toUpperCase(Locale.ROOT); | ||
} | ||
|
||
public Endpoint(String listenerName, SecurityProtocol securityProtocol, String host, int port) { | ||
this.listenerName = listenerName; | ||
this.securityProtocol = securityProtocol; | ||
this.host = host; | ||
this.port = port; | ||
} | ||
|
||
/** | ||
* Returns the listener name of this endpoint. | ||
*/ | ||
public String listener() { | ||
return listenerName; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about renaming it to |
||
} | ||
|
||
/** | ||
* Returns the listener name of this endpoint. This is non-empty for endpoints provided | ||
* to broker plugins, but may be empty when used in clients. | ||
* @deprecated Since 4.1. Use {@link #listener} instead. This function will be removed in 5.0. | ||
*/ | ||
@Deprecated | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
public Optional<String> listenerName() { | ||
return Optional.ofNullable(listenerName); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Deprecated(since = "4.1", forRemoval = true)