Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public AbstractConfig(ConfigDef definition, Map<?, ?> originals, Map<String, ?>
* @param originals the configuration properties plus any optional config provider properties; may not be null
*/
public AbstractConfig(ConfigDef definition, Map<?, ?> originals) {
this(definition, originals, Collections.emptyMap(), true);
this(definition, originals, Map.of(), true);
}

/**
Expand All @@ -146,7 +146,7 @@ public AbstractConfig(ConfigDef definition, Map<?, ?> originals) {
* @param doLog whether the configurations should be logged
*/
public AbstractConfig(ConfigDef definition, Map<?, ?> originals, boolean doLog) {
this(definition, originals, Collections.emptyMap(), doLog);
this(definition, originals, Map.of(), doLog);
}

/**
Expand All @@ -168,7 +168,7 @@ protected Map<String, Object> preProcessParsedConfig(Map<String, Object> parsedV
* @return a map of updates that should be applied to the configuration (will be validated to prevent bad updates)
*/
protected Map<String, Object> postProcessParsedConfig(Map<String, Object> parsedValues) {
return Collections.emptyMap();
return Map.of();
}

protected Object get(String key) {
Expand Down Expand Up @@ -430,7 +430,7 @@ private <T> T getConfiguredInstance(Object klass, Class<T> t, Map<String, Object
* @return A configured instance of the class
*/
public <T> T getConfiguredInstance(String key, Class<T> t) {
return getConfiguredInstance(key, t, Collections.emptyMap());
return getConfiguredInstance(key, t, Map.of());
}

/**
Expand Down Expand Up @@ -458,7 +458,7 @@ public <T> T getConfiguredInstance(String key, Class<T> t, Map<String, Object> c
* @return The list of configured instances
*/
public <T> List<T> getConfiguredInstances(String key, Class<T> t) {
return getConfiguredInstances(key, t, Collections.emptyMap());
return getConfiguredInstances(key, t, Map.of());
}

/**
Expand Down Expand Up @@ -606,7 +606,7 @@ private Map<String, ConfigProvider> instantiateConfigProviders(
final String configProviders = indirectConfigs.get(CONFIG_PROVIDERS_CONFIG);

if (configProviders == null || configProviders.isEmpty()) {
return Collections.emptyMap();
return Map.of();
}

Map<String, String> providerMap = new HashMap<>();
Expand Down
26 changes: 13 additions & 13 deletions clients/src/main/java/org/apache/kafka/common/config/ConfigDef.java
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public ConfigDef define(String name, Type type, Object defaultValue, Validator v
*/
public ConfigDef define(String name, Type type, Object defaultValue, Validator validator, Importance importance, String documentation,
String group, int orderInGroup, Width width, String displayName, Recommender recommender) {
return define(name, type, defaultValue, validator, importance, documentation, group, orderInGroup, width, displayName, Collections.emptyList(), recommender);
return define(name, type, defaultValue, validator, importance, documentation, group, orderInGroup, width, displayName, List.of(), recommender);
}

/**
Expand All @@ -237,7 +237,7 @@ public ConfigDef define(String name, Type type, Object defaultValue, Validator v
*/
public ConfigDef define(String name, Type type, Object defaultValue, Validator validator, Importance importance, String documentation,
String group, int orderInGroup, Width width, String displayName) {
return define(name, type, defaultValue, validator, importance, documentation, group, orderInGroup, width, displayName, Collections.emptyList());
return define(name, type, defaultValue, validator, importance, documentation, group, orderInGroup, width, displayName, List.of());
}

/**
Expand Down Expand Up @@ -295,7 +295,7 @@ public ConfigDef define(String name, Type type, Object defaultValue, Importance
*/
public ConfigDef define(String name, Type type, Object defaultValue, Importance importance, String documentation,
String group, int orderInGroup, Width width, String displayName, Recommender recommender) {
return define(name, type, defaultValue, null, importance, documentation, group, orderInGroup, width, displayName, Collections.emptyList(), recommender);
return define(name, type, defaultValue, null, importance, documentation, group, orderInGroup, width, displayName, List.of(), recommender);
}

/**
Expand All @@ -313,7 +313,7 @@ public ConfigDef define(String name, Type type, Object defaultValue, Importance
*/
public ConfigDef define(String name, Type type, Object defaultValue, Importance importance, String documentation,
String group, int orderInGroup, Width width, String displayName) {
return define(name, type, defaultValue, null, importance, documentation, group, orderInGroup, width, displayName, Collections.emptyList());
return define(name, type, defaultValue, null, importance, documentation, group, orderInGroup, width, displayName, List.of());
}

/**
Expand Down Expand Up @@ -368,7 +368,7 @@ public ConfigDef define(String name, Type type, Importance importance, String do
*/
public ConfigDef define(String name, Type type, Importance importance, String documentation, String group, int orderInGroup,
Width width, String displayName, Recommender recommender) {
return define(name, type, NO_DEFAULT_VALUE, null, importance, documentation, group, orderInGroup, width, displayName, Collections.emptyList(), recommender);
return define(name, type, NO_DEFAULT_VALUE, null, importance, documentation, group, orderInGroup, width, displayName, List.of(), recommender);
}

/**
Expand All @@ -385,7 +385,7 @@ public ConfigDef define(String name, Type type, Importance importance, String do
*/
public ConfigDef define(String name, Type type, Importance importance, String documentation, String group, int orderInGroup,
Width width, String displayName) {
return define(name, type, NO_DEFAULT_VALUE, null, importance, documentation, group, orderInGroup, width, displayName, Collections.emptyList());
return define(name, type, NO_DEFAULT_VALUE, null, importance, documentation, group, orderInGroup, width, displayName, List.of());
}

/**
Expand Down Expand Up @@ -427,7 +427,7 @@ public ConfigDef define(String name, Type type, Object defaultValue, Importance
*/
public ConfigDef define(String name, Type type, Object defaultValue, Importance importance, String documentation, String alternativeString) {
return define(name, type, defaultValue, null, importance, documentation, null, -1, Width.NONE,
name, Collections.emptyList(), null, alternativeString);
name, List.of(), null, alternativeString);
}

/**
Expand All @@ -452,7 +452,7 @@ public ConfigDef define(String name, Type type, Importance importance, String do
* @return This ConfigDef so you can chain calls
*/
public ConfigDef defineInternal(final String name, final Type type, final Object defaultValue, final Importance importance) {
return define(new ConfigKey(name, type, defaultValue, null, importance, "", "", -1, Width.NONE, name, Collections.emptyList(), null, true, null));
return define(new ConfigKey(name, type, defaultValue, null, importance, "", "", -1, Width.NONE, name, List.of(), null, true, null));
}

/**
Expand All @@ -467,7 +467,7 @@ public ConfigDef defineInternal(final String name, final Type type, final Object
* @return This ConfigDef so you can chain calls
*/
public ConfigDef defineInternal(final String name, final Type type, final Object defaultValue, final Validator validator, final Importance importance, final String documentation) {
return define(new ConfigKey(name, type, defaultValue, validator, importance, documentation, "", -1, Width.NONE, name, Collections.emptyList(), null, true, null));
return define(new ConfigKey(name, type, defaultValue, validator, importance, documentation, "", -1, Width.NONE, name, List.of(), null, true, null));
}

/**
Expand Down Expand Up @@ -768,7 +768,7 @@ else if (value instanceof String)
return value;
else if (value instanceof String)
if (trimmed.isEmpty())
return Collections.emptyList();
return List.of();
else
return Arrays.asList(COMMA_WITH_WHITESPACE.split(trimmed, -1));
else
Expand Down Expand Up @@ -1445,7 +1445,7 @@ static String niceTimeUnits(long millis) {
}

public String toHtmlTable() {
return toHtmlTable(Collections.emptyMap());
return toHtmlTable(Map.of());
}

private void addHeader(StringBuilder builder, String headerName) {
Expand Down Expand Up @@ -1700,7 +1700,7 @@ public boolean visible(String name, Map<String, Object> parsedConfig) {
}

public String toHtml() {
return toHtml(Collections.emptyMap());
return toHtml(Map.of());
}

/**
Expand All @@ -1709,7 +1709,7 @@ public String toHtml() {
* @param idGenerator A function for computing the HTML id attribute in the generated HTML from a given config name.
*/
public String toHtml(int headerDepth, Function<String, String> idGenerator) {
return toHtml(headerDepth, idGenerator, Collections.emptyMap());
return toHtml(headerDepth, idGenerator, Map.of());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.apache.kafka.common.security.authenticator.DefaultKafkaPrincipalBuilder;
import org.apache.kafka.common.utils.Utils;

import java.util.Collections;
import java.util.List;

import static org.apache.kafka.common.config.ConfigDef.Importance.LOW;
Expand Down Expand Up @@ -61,7 +60,7 @@ public class BrokerSecurityConfigs {
" configuration.";

public static final String SASL_KERBEROS_PRINCIPAL_TO_LOCAL_RULES_CONFIG = "sasl.kerberos.principal.to.local.rules";
public static final List<String> DEFAULT_SASL_KERBEROS_PRINCIPAL_TO_LOCAL_RULES = Collections.singletonList(DEFAULT_SSL_PRINCIPAL_MAPPING_RULES);
public static final List<String> DEFAULT_SASL_KERBEROS_PRINCIPAL_TO_LOCAL_RULES = List.of(DEFAULT_SSL_PRINCIPAL_MAPPING_RULES);
public static final String SASL_KERBEROS_PRINCIPAL_TO_LOCAL_RULES_DOC = "A list of rules for mapping from principal " +
"names to short names (typically operating system usernames). The rules are evaluated in order and the " +
"first rule that matches a principal name is used to map it to a short name. Any later rules in the list are " +
Expand Down Expand Up @@ -95,7 +94,7 @@ public class BrokerSecurityConfigs {
+ "</ul>";

public static final String SASL_ENABLED_MECHANISMS_CONFIG = "sasl.enabled.mechanisms";
public static final List<String> DEFAULT_SASL_ENABLED_MECHANISMS = Collections.singletonList(SaslConfigs.GSSAPI_MECHANISM);
public static final List<String> DEFAULT_SASL_ENABLED_MECHANISMS = List.of(SaslConfigs.GSSAPI_MECHANISM);
public static final String SASL_ENABLED_MECHANISMS_DOC = "The list of SASL mechanisms enabled in the Kafka server. "
+ "The list may contain any mechanism for which a security provider is available. "
+ "Only GSSAPI is enabled by default.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static java.util.Collections.emptyMap;

/**
* An implementation of {@link ConfigProvider} based on a directory of files.
Expand Down Expand Up @@ -87,7 +86,7 @@ private ConfigData get(String path, Predicate<Path> fileFilter) {
throw new IllegalStateException("The provider has not been configured yet.");
}

Map<String, String> map = emptyMap();
Map<String, String> map = Map.of();

if (path != null && !path.isEmpty()) {
Path dir = allowedPaths.parseUntrustedPath(path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package org.apache.kafka.common.errors;

import java.util.Collections;
import java.util.Set;

public class TopicAuthorizationException extends AuthorizationException {
Expand All @@ -32,7 +31,7 @@ public TopicAuthorizationException(Set<String> unauthorizedTopics) {
}

public TopicAuthorizationException(String message) {
this(message, Collections.emptySet());
this(message, Set.of());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

import java.nio.ByteBuffer;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumMap;
import java.util.Map;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -65,7 +64,7 @@ final ByteBufferAccessor serialize(short version) {
public abstract Map<Errors, Integer> errorCounts();

protected static Map<Errors, Integer> errorCounts(Errors error) {
return Collections.singletonMap(error, 1);
return Map.of(error, 1);
}

protected static Map<Errors, Integer> errorCounts(Stream<Errors> errors) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.apache.kafka.common.protocol.Errors;
import org.apache.kafka.common.protocol.Readable;

import java.util.Collections;
import java.util.Map;

public class AddRaftVoterResponse extends AbstractResponse {
Expand Down Expand Up @@ -51,9 +50,9 @@ public void maybeSetThrottleTimeMs(int throttleTimeMs) {
@Override
public Map<Errors, Integer> errorCounts() {
if (data.errorCode() != Errors.NONE.code()) {
return Collections.singletonMap(Errors.forCode(data.errorCode()), 1);
return Map.of(Errors.forCode(data.errorCode()), 1);
} else {
return Collections.emptyMap();
return Map.of();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.apache.kafka.common.protocol.Errors;
import org.apache.kafka.common.protocol.Readable;

import java.util.Collections;
import java.util.Map;

public class AllocateProducerIdsResponse extends AbstractResponse {
Expand All @@ -47,7 +46,7 @@ public AllocateProducerIdsResponseData data() {
*/
@Override
public Map<Errors, Integer> errorCounts() {
return Collections.singletonMap(Errors.forCode(data.errorCode()), 1);
return Map.of(Errors.forCode(data.errorCode()), 1);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.apache.kafka.common.protocol.Readable;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -90,7 +89,7 @@ public AlterPartitionRequest build(short version) {
newIsr.add(brokerState.brokerId())
);
partitionData.setNewIsr(newIsr);
partitionData.setNewIsrWithEpochs(Collections.emptyList());
partitionData.setNewIsrWithEpochs(List.of());
}
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.apache.kafka.common.protocol.Errors;
import org.apache.kafka.common.protocol.Readable;

import java.util.Collections;
import java.util.Map;

public class AssignReplicasToDirsResponse extends AbstractResponse {
Expand All @@ -40,7 +39,7 @@ public AssignReplicasToDirsResponseData data() {

@Override
public Map<Errors, Integer> errorCounts() {
return Collections.singletonMap(Errors.forCode(data.errorCode()), 1);
return Map.of(Errors.forCode(data.errorCode()), 1);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
import org.apache.kafka.common.protocol.Errors;
import org.apache.kafka.common.protocol.Readable;

import java.util.Collections;
import java.util.List;


public class BeginQuorumEpochRequest extends AbstractRequest {
public static class Builder extends AbstractRequest.Builder<BeginQuorumEpochRequest> {
Expand Down Expand Up @@ -75,10 +76,10 @@ public static BeginQuorumEpochRequestData singletonRequest(
) {
return new BeginQuorumEpochRequestData()
.setClusterId(clusterId)
.setTopics(Collections.singletonList(
.setTopics(List.of(
new BeginQuorumEpochRequestData.TopicData()
.setTopicName(topicPartition.topic())
.setPartitions(Collections.singletonList(
.setPartitions(List.of(
new BeginQuorumEpochRequestData.PartitionData()
.setPartitionIndex(topicPartition.partition())
.setLeaderEpoch(leaderEpoch)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.apache.kafka.common.protocol.Readable;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -59,7 +58,7 @@ public ConsumerGroupHeartbeatResponseData data() {

@Override
public Map<Errors, Integer> errorCounts() {
return Collections.singletonMap(Errors.forCode(data.errorCode()), 1);
return Map.of(Errors.forCode(data.errorCode()), 1);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.apache.kafka.common.protocol.Errors;
import org.apache.kafka.common.protocol.Readable;

import java.util.Collections;
import java.util.Map;

public class ControllerRegistrationResponse extends AbstractResponse {
Expand Down Expand Up @@ -50,7 +49,7 @@ public void maybeSetThrottleTimeMs(int throttleTimeMs) {

@Override
public Map<Errors, Integer> errorCounts() {
return Collections.singletonMap(Errors.forCode(data.errorCode()), 1);
return Map.of(Errors.forCode(data.errorCode()), 1);
}

public static ControllerRegistrationResponse parse(Readable readable, short version) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.apache.kafka.common.protocol.Readable;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -104,7 +103,7 @@ public int numberOfTopics() {
public List<Uuid> topicIds() {
if (version() >= 6)
return data.topics().stream().map(DeleteTopicState::topicId).collect(Collectors.toList());
return Collections.emptyList();
return List.of();
}

public List<DeleteTopicState> topics() {
Expand Down
Loading
Loading