Skip to content

Commit 1b51887

Browse files
Merge branch 'apache:trunk' into trunk
2 parents 362557f + 116762f commit 1b51887

File tree

60 files changed

+1573
-1422
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1573
-1422
lines changed

Diff for: build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,6 @@ if (repo != null) {
208208
'licenses/*',
209209
'**/generated/**',
210210
'clients/src/test/resources/serializedData/*',
211-
'docker/resources/utility/go.sum',
212211
'docker/test/fixtures/secrets/*',
213212
'docker/examples/fixtures/secrets/*'
214213
])
@@ -303,7 +302,7 @@ subprojects {
303302
from components.java
304303
} else {
305304
apply plugin: 'com.github.johnrengelman.shadow'
306-
project.shadow.component(mavenJava)
305+
artifact shadowJar
307306
}
308307

309308
afterEvaluate {
@@ -1582,6 +1581,7 @@ project(':raft') {
15821581
implementation libs.jacksonDatabind
15831582

15841583
testImplementation project(':server-common')
1584+
testImplementation project(':server-common').sourceSets.test.output
15851585
testImplementation project(':clients')
15861586
testImplementation project(':clients').sourceSets.test.output
15871587
testImplementation libs.junitJupiter

Diff for: checkstyle/import-control.xml

+1
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,7 @@
441441
<allow pkg="org.apache.kafka.common.protocol" />
442442
<allow pkg="org.apache.kafka.server.common" />
443443
<allow pkg="org.apache.kafka.server.common.serialization" />
444+
<allow pkg="org.apache.kafka.server.fault"/>
444445
<allow pkg="org.apache.kafka.server.util" />
445446
<allow pkg="org.apache.kafka.test"/>
446447
<allow pkg="com.fasterxml.jackson" />

Diff for: clients/src/test/java/org/apache/kafka/clients/admin/MockAdminClient.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,13 @@ synchronized public DescribeLogDirsResult describeLogDirs(Collection<Integer> br
10171017
for (Node node : nodes) {
10181018
Map<String, LogDirDescription> logDirDescriptionMap = unwrappedResults.get(node.id());
10191019
LogDirDescription logDirDescription = logDirDescriptionMap.getOrDefault(partitionLogDirs.get(0), new LogDirDescription(null, new HashMap<>()));
1020-
logDirDescription.replicaInfos().put(new TopicPartition(topicName, topicPartitionInfo.partition()), new ReplicaInfo(0, 0, false));
1020+
Map<TopicPartition, ReplicaInfo> topicPartitionReplicaInfoMap = new HashMap<>(logDirDescription.replicaInfos());
1021+
topicPartitionReplicaInfoMap.put(new TopicPartition(topicName, topicPartitionInfo.partition()), new ReplicaInfo(0, 0, false));
1022+
logDirDescriptionMap.put(partitionLogDirs.get(0), new LogDirDescription(
1023+
logDirDescription.error(),
1024+
topicPartitionReplicaInfoMap,
1025+
logDirDescription.totalBytes().orElse(DescribeLogDirsResponse.UNKNOWN_VOLUME_BYTES),
1026+
logDirDescription.usableBytes().orElse(DescribeLogDirsResponse.UNKNOWN_VOLUME_BYTES)));
10211027
}
10221028
}
10231029
}

Diff for: connect/basic-auth-extension/src/main/java/org/apache/kafka/connect/rest/basic/auth/extension/BasicAuthSecurityRestExtension.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import org.slf4j.LoggerFactory;
2626

2727
import javax.security.auth.login.Configuration;
28-
import java.io.IOException;
2928
import java.util.Map;
3029
import java.util.function.Supplier;
3130

@@ -100,7 +99,7 @@ public void register(ConnectRestExtensionContext restPluginContext) {
10099
}
101100

102101
@Override
103-
public void close() throws IOException {
102+
public void close() {
104103

105104
}
106105

Diff for: connect/basic-auth-extension/src/main/java/org/apache/kafka/connect/rest/basic/auth/extension/JaasBasicAuthFilter.java

+4-6
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,13 @@
3434
import org.slf4j.Logger;
3535
import org.slf4j.LoggerFactory;
3636

37-
import java.io.IOException;
3837
import java.nio.charset.StandardCharsets;
3938
import java.util.Base64;
4039

4140
import javax.security.auth.callback.Callback;
4241
import javax.security.auth.callback.CallbackHandler;
4342
import javax.security.auth.callback.NameCallback;
4443
import javax.security.auth.callback.PasswordCallback;
45-
import javax.security.auth.callback.UnsupportedCallbackException;
4644
import javax.security.auth.login.LoginContext;
4745
import javax.security.auth.login.LoginException;
4846
import javax.ws.rs.Priorities;
@@ -87,7 +85,7 @@ public JaasBasicAuthFilter(Configuration configuration) {
8785
}
8886

8987
@Override
90-
public void filter(ContainerRequestContext requestContext) throws IOException {
88+
public void filter(ContainerRequestContext requestContext) {
9189
if (isInternalRequest(requestContext)) {
9290
log.trace("Skipping authentication for internal request");
9391
return;
@@ -119,16 +117,16 @@ private boolean isInternalRequest(ContainerRequestContext requestContext) {
119117

120118
public static class BasicAuthCallBackHandler implements CallbackHandler {
121119

122-
private String username;
123-
private String password;
120+
private final String username;
121+
private final String password;
124122

125123
public BasicAuthCallBackHandler(BasicAuthCredentials credentials) {
126124
username = credentials.username();
127125
password = credentials.password();
128126
}
129127

130128
@Override
131-
public void handle(Callback[] callbacks) throws UnsupportedCallbackException {
129+
public void handle(Callback[] callbacks) {
132130
List<Callback> unsupportedCallbacks = new ArrayList<>();
133131
for (Callback callback : callbacks) {
134132
if (callback instanceof NameCallback) {

Diff for: connect/basic-auth-extension/src/main/java/org/apache/kafka/connect/rest/basic/auth/extension/PropertyFileLoginModule.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public class PropertyFileLoginModule implements LoginModule {
5454
private String fileName;
5555
private boolean authenticated;
5656

57-
private static Map<String, Properties> credentialPropertiesMap = new ConcurrentHashMap<>();
57+
private static final Map<String, Properties> CREDENTIAL_PROPERTIES = new ConcurrentHashMap<>();
5858

5959
@Override
6060
public void initialize(Subject subject, CallbackHandler callbackHandler, Map<String, ?> sharedState, Map<String, ?> options) {
@@ -64,15 +64,15 @@ public void initialize(Subject subject, CallbackHandler callbackHandler, Map<Str
6464
throw new ConfigException("Property Credentials file must be specified");
6565
}
6666

67-
if (!credentialPropertiesMap.containsKey(fileName)) {
67+
if (!CREDENTIAL_PROPERTIES.containsKey(fileName)) {
6868
log.trace("Opening credential properties file '{}'", fileName);
6969
Properties credentialProperties = new Properties();
7070
try {
7171
try (InputStream inputStream = Files.newInputStream(Paths.get(fileName))) {
7272
log.trace("Parsing credential properties file '{}'", fileName);
7373
credentialProperties.load(inputStream);
7474
}
75-
credentialPropertiesMap.putIfAbsent(fileName, credentialProperties);
75+
CREDENTIAL_PROPERTIES.putIfAbsent(fileName, credentialProperties);
7676
if (credentialProperties.isEmpty())
7777
log.warn("Credential properties file '{}' is empty; all requests will be permitted",
7878
fileName);
@@ -101,7 +101,7 @@ public boolean login() throws LoginException {
101101
String username = ((NameCallback) callbacks[0]).getName();
102102
char[] passwordChars = ((PasswordCallback) callbacks[1]).getPassword();
103103
String password = passwordChars != null ? new String(passwordChars) : null;
104-
Properties credentialProperties = credentialPropertiesMap.get(fileName);
104+
Properties credentialProperties = CREDENTIAL_PROPERTIES.get(fileName);
105105

106106
if (credentialProperties.isEmpty()) {
107107
log.trace("Not validating credentials for user '{}' as credential properties file '{}' is empty",
@@ -132,17 +132,17 @@ public boolean login() throws LoginException {
132132
}
133133

134134
@Override
135-
public boolean commit() throws LoginException {
135+
public boolean commit() {
136136
return authenticated;
137137
}
138138

139139
@Override
140-
public boolean abort() throws LoginException {
140+
public boolean abort() {
141141
return true;
142142
}
143143

144144
@Override
145-
public boolean logout() throws LoginException {
145+
public boolean logout() {
146146
return true;
147147
}
148148

Diff for: connect/basic-auth-extension/src/test/java/org/apache/kafka/connect/rest/basic/auth/extension/JaasBasicAuthFilterTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public void testUnknownLoginModule() throws IOException {
131131
}
132132

133133
@Test
134-
public void testUnknownCredentialsFile() throws IOException {
134+
public void testUnknownCredentialsFile() {
135135
JaasBasicAuthFilter jaasBasicAuthFilter = setupJaasFilter("KafkaConnect", "/tmp/testcrednetial");
136136
ContainerRequestContext requestContext = setMock("Basic", "user", "password");
137137
jaasBasicAuthFilter.filter(requestContext);
@@ -142,7 +142,7 @@ public void testUnknownCredentialsFile() throws IOException {
142142
}
143143

144144
@Test
145-
public void testNoFileOption() throws IOException {
145+
public void testNoFileOption() {
146146
JaasBasicAuthFilter jaasBasicAuthFilter = setupJaasFilter("KafkaConnect", null);
147147
ContainerRequestContext requestContext = setMock("Basic", "user", "password");
148148
jaasBasicAuthFilter.filter(requestContext);

Diff for: connect/file/src/test/java/org/apache/kafka/connect/file/FileStreamSinkTaskTest.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ public class FileStreamSinkTaskTest {
4040

4141
private FileStreamSinkTask task;
4242
private ByteArrayOutputStream os;
43-
private PrintStream printStream;
4443

4544
@TempDir
4645
public Path topDir;
@@ -49,7 +48,7 @@ public class FileStreamSinkTaskTest {
4948
@BeforeEach
5049
public void setup() {
5150
os = new ByteArrayOutputStream();
52-
printStream = new PrintStream(os);
51+
PrintStream printStream = new PrintStream(os);
5352
task = new FileStreamSinkTask(printStream);
5453
outputFile = topDir.resolve("connect.output").toAbsolutePath().toString();
5554
}

Diff for: core/src/main/scala/kafka/admin/ConfigCommand.scala

+7-7
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import java.util.concurrent.TimeUnit
2222
import java.util.{Collections, Properties}
2323
import joptsimple._
2424
import kafka.server.DynamicConfig.QuotaConfigs
25-
import kafka.server.{ConfigEntityName, Defaults, DynamicBrokerConfig, DynamicConfig, KafkaConfig}
25+
import kafka.server.{Defaults, DynamicBrokerConfig, DynamicConfig, KafkaConfig}
2626
import kafka.utils.{Exit, Logging, PasswordEncoder}
2727
import kafka.utils.Implicits._
2828
import kafka.zk.{AdminZkClient, KafkaZkClient}
@@ -35,7 +35,7 @@ import org.apache.kafka.common.quota.{ClientQuotaAlteration, ClientQuotaEntity,
3535
import org.apache.kafka.common.security.JaasUtils
3636
import org.apache.kafka.common.security.scram.internals.{ScramCredentialUtils, ScramFormatter, ScramMechanism}
3737
import org.apache.kafka.common.utils.{Sanitizer, Time, Utils}
38-
import org.apache.kafka.server.config.ConfigType
38+
import org.apache.kafka.server.config.{ConfigEntityName, ConfigType}
3939
import org.apache.kafka.server.util.{CommandDefaultOptions, CommandLineUtils}
4040
import org.apache.kafka.storage.internals.log.LogConfig
4141
import org.apache.zookeeper.client.ZKClientConfig
@@ -152,7 +152,7 @@ object ConfigCommand extends Logging {
152152
if (!configsToBeAdded.isEmpty || configsToBeDeleted.nonEmpty) {
153153
validateBrokersNotRunning(entityName, adminZkClient, zkClient, errorMessage)
154154

155-
val perBrokerConfig = entityName != ConfigEntityName.Default
155+
val perBrokerConfig = entityName != ConfigEntityName.DEFAULT
156156
preProcessBrokerConfigs(configsToBeAdded, perBrokerConfig)
157157
}
158158
}
@@ -177,7 +177,7 @@ object ConfigCommand extends Logging {
177177
adminZkClient: AdminZkClient,
178178
zkClient: KafkaZkClient,
179179
errorMessage: String): Unit = {
180-
val perBrokerConfig = entityName != ConfigEntityName.Default
180+
val perBrokerConfig = entityName != ConfigEntityName.DEFAULT
181181
val info = "Broker configuration operations using ZooKeeper are only supported if the affected broker(s) are not running."
182182
if (perBrokerConfig) {
183183
adminZkClient.parseBroker(entityName).foreach { brokerId =>
@@ -696,7 +696,7 @@ object ConfigCommand extends Logging {
696696
case t => t
697697
}
698698
sanitizedName match {
699-
case Some(ConfigEntityName.Default) => "default " + typeName
699+
case Some(ConfigEntityName.DEFAULT) => "default " + typeName
700700
case Some(n) =>
701701
val desanitized = if (entityType == ConfigType.USER || entityType == ConfigType.CLIENT) Sanitizer.desanitize(n) else n
702702
s"$typeName '$desanitized'"
@@ -757,7 +757,7 @@ object ConfigCommand extends Logging {
757757
else {
758758
// Exactly one entity type and at-most one entity name expected for other entities
759759
val name = entityNames.headOption match {
760-
case Some("") => Some(ConfigEntityName.Default)
760+
case Some("") => Some(ConfigEntityName.DEFAULT)
761761
case v => v
762762
}
763763
ConfigEntity(Entity(entityTypes.head, name), None)
@@ -774,7 +774,7 @@ object ConfigCommand extends Logging {
774774

775775
def sanitizeName(entityType: String, name: String) = {
776776
if (name.isEmpty)
777-
ConfigEntityName.Default
777+
ConfigEntityName.DEFAULT
778778
else {
779779
entityType match {
780780
case ConfigType.USER | ConfigType.CLIENT => Sanitizer.sanitize(name)

0 commit comments

Comments
 (0)