Skip to content

Commit

Permalink
KAFKA-10787 Apply spotless to transaction-coordinator and server-comm…
Browse files Browse the repository at this point in the history
…on (apache#16172)

Reviewers: Chia-Ping Tsai <[email protected]>
  • Loading branch information
gongxuanzhang committed Jun 12, 2024
1 parent cc1202d commit a454f2a
Show file tree
Hide file tree
Showing 56 changed files with 186 additions and 128 deletions.
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ def excludedSpotlessModules = [':clients',
':metadata',
':raft',
':server',
':server-common',
':shell',
':storage',
':storage:storage-api', // rename in settings.gradle
Expand Down Expand Up @@ -254,7 +253,6 @@ def excludedSpotlessModules = [':clients',
':streams:upgrade-system-tests-37',
':tools',
':tools:tools-api',
':transaction-coordinator',
':trogdor']


Expand Down Expand Up @@ -842,8 +840,10 @@ subprojects {
skipProjects = [ ":jmh-benchmarks", ":trogdor" ]
skipConfigurations = [ "zinc" ]
}

if(JavaVersion.current().isJava11Compatible() && project.path !in excludedSpotlessModules) {
// the task `removeUnusedImports` is implemented by google-java-format,
// and unfortunately the google-java-format version used by spotless 6.14.0 can't work with JDK 21.
// Hence, we apply spotless tasks only if the env is either JDK11 or JDK17
if ((JavaVersion.current().isJava11() || (JavaVersion.current() == JavaVersion.VERSION_17)) && project.path !in excludedSpotlessModules) {
apply plugin: 'com.diffplug.spotless'
spotless {
java {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.kafka.deferred;

import org.apache.kafka.common.utils.LogContext;

import org.slf4j.Logger;

import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@

package org.apache.kafka.queue;

import org.apache.kafka.common.errors.TimeoutException;
import org.apache.kafka.common.utils.KafkaThread;
import org.apache.kafka.common.utils.LogContext;
import org.apache.kafka.common.utils.Time;

import org.slf4j.Logger;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
Expand All @@ -28,12 +35,6 @@
import java.util.concurrent.locks.ReentrantLock;
import java.util.function.Function;

import org.apache.kafka.common.errors.TimeoutException;
import org.apache.kafka.common.utils.KafkaThread;
import org.apache.kafka.common.utils.LogContext;
import org.apache.kafka.common.utils.Time;
import org.slf4j.Logger;


public final class KafkaEventQueue implements EventQueue {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@
import org.apache.kafka.common.config.types.Password;
import org.apache.kafka.server.util.Csv;

import javax.crypto.Cipher;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.SecretKeySpec;
import java.nio.charset.StandardCharsets;
import java.security.GeneralSecurityException;
import java.security.NoSuchAlgorithmException;
Expand All @@ -33,6 +29,11 @@
import java.util.Map;
import java.util.stream.Collectors;

import javax.crypto.Cipher;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.SecretKeySpec;

/**
* Password encoder and decoder implementation. Encoded passwords are persisted as a CSV map
* containing the encoded password in base64 and along with the properties used for encryption.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
*/
package org.apache.kafka.security;

import javax.crypto.spec.GCMParameterSpec;
import java.security.AlgorithmParameters;
import java.security.spec.AlgorithmParameterSpec;
import java.security.spec.InvalidParameterSpecException;
import java.util.HashMap;
import java.util.Map;

import javax.crypto.spec.GCMParameterSpec;

public class GcmParamsEncoder implements CipherParamsEncoder {

private static final String AUTHENTICATION_TAG_LENGTH = "authenticationTagLength";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
*/
package org.apache.kafka.security;

import javax.crypto.spec.IvParameterSpec;
import java.security.AlgorithmParameters;
import java.security.spec.AlgorithmParameterSpec;
import java.security.spec.InvalidParameterSpecException;
import java.util.Collections;
import java.util.Map;

import javax.crypto.spec.IvParameterSpec;

public class IvParamsEncoder implements CipherParamsEncoder {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
*/
package org.apache.kafka.server.common;

import org.apache.kafka.common.record.RecordVersion;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.regex.Pattern;
import org.apache.kafka.common.record.RecordVersion;

/**
* This class contains the different Kafka versions.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
*/
package org.apache.kafka.server.common;

import java.util.Arrays;
import java.util.stream.Collectors;
import org.apache.kafka.common.config.ConfigDef.Validator;
import org.apache.kafka.common.config.ConfigException;

import java.util.Arrays;
import java.util.stream.Collectors;

public class MetadataVersionValidator implements Validator {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import org.apache.kafka.common.config.ConfigDef;
import org.apache.kafka.common.security.scram.internals.ScramMechanism;

import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
*/
package org.apache.kafka.server.config;

import static java.util.Arrays.asList;
import org.apache.kafka.common.config.TopicConfig;
import org.apache.kafka.common.utils.Utils;

import java.util.Arrays;
import java.util.Collections;
Expand All @@ -25,8 +26,8 @@
import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.stream.Collectors;
import org.apache.kafka.common.config.TopicConfig;
import org.apache.kafka.common.utils.Utils;

import static java.util.Arrays.asList;

public final class ServerTopicConfigSynonyms {
public static final String LOG_PREFIX = "log.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@

package org.apache.kafka.server.fault;

import java.util.Objects;
import org.apache.kafka.common.utils.Exit;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Objects;

/**
* This is a fault handler which terminates the JVM process.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.kafka.server.immutable.pcollections;

import org.apache.kafka.server.immutable.ImmutableMap;

import org.pcollections.HashPMap;
import org.pcollections.HashTreePMap;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.kafka.server.immutable.pcollections;

import org.apache.kafka.server.immutable.ImmutableNavigableSet;

import org.pcollections.TreePSet;

import java.util.Collection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.kafka.server.immutable.pcollections;

import org.apache.kafka.server.immutable.ImmutableSet;

import org.pcollections.HashTreePSet;
import org.pcollections.MapPSet;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,20 @@
*/
package org.apache.kafka.server.metrics;

import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import org.apache.kafka.common.utils.Sanitizer;

import com.yammer.metrics.core.Gauge;
import com.yammer.metrics.core.Histogram;
import com.yammer.metrics.core.Meter;
import com.yammer.metrics.core.MetricName;
import com.yammer.metrics.core.Timer;
import org.apache.kafka.common.utils.Sanitizer;

import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

public class KafkaMetricsGroup {
private final Class<?> klass;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@

package org.apache.kafka.server.metrics;

import com.yammer.metrics.core.MetricName;
import com.yammer.metrics.core.MetricsRegistry;
import org.apache.kafka.common.Reconfigurable;
import org.apache.kafka.common.config.ConfigException;
import org.apache.kafka.common.metrics.JmxReporter;
import org.apache.kafka.common.utils.Exit;
import org.apache.kafka.common.utils.Sanitizer;

import com.yammer.metrics.core.MetricName;
import com.yammer.metrics.core.MetricsRegistry;

import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.kafka.common.utils.LogContext;
import org.apache.kafka.server.authorizer.Authorizer;
import org.apache.kafka.server.authorizer.AuthorizerServerInfo;

import org.slf4j.Logger;

import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
*/
package org.apache.kafka.server.util;

import joptsimple.OptionParser;
import joptsimple.OptionSet;
import joptsimple.OptionSpec;
import org.apache.kafka.clients.CommonClientConfigs;
import org.apache.kafka.clients.admin.AdminClientConfig;
import org.apache.kafka.common.utils.AppInfoParser;
Expand All @@ -31,6 +28,10 @@
import java.util.Properties;
import java.util.Set;

import joptsimple.OptionParser;
import joptsimple.OptionSet;
import joptsimple.OptionSpec;

/**
* Helper functions for dealing with command line utilities.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.apache.kafka.server.util;

import org.apache.kafka.common.utils.Time;

import org.slf4j.Logger;

import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,6 @@
*/
package org.apache.kafka.server.util;

import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.apache.kafka.clients.ClientRequest;
import org.apache.kafka.clients.ClientResponse;
import org.apache.kafka.clients.KafkaClient;
Expand All @@ -37,6 +27,17 @@
import org.apache.kafka.common.utils.Time;
import org.apache.kafka.common.utils.Utils;

import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

/**
* An inter-broker send thread that utilizes a non-blocking network client.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@

package org.apache.kafka.server.util;

import org.apache.kafka.server.util.json.JsonValue;

import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.MissingNode;
import org.apache.kafka.server.util.json.JsonValue;

import java.io.IOException;
import java.util.Optional;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.apache.kafka.server.util;

import org.apache.kafka.common.utils.KafkaThread;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.apache.kafka.common.internals.FatalExitError;
import org.apache.kafka.common.utils.Exit;
import org.apache.kafka.common.utils.LogContext;

import org.slf4j.Logger;

import java.util.concurrent.CountDownLatch;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,3 @@ public void wakeup() {
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.apache.kafka.server.util;

import org.apache.kafka.common.internals.Topic;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@

package org.apache.kafka.timeline;

import org.apache.kafka.common.utils.LogContext;

import org.slf4j.Logger;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;

import org.apache.kafka.common.utils.LogContext;
import org.slf4j.Logger;


/**
* A registry containing snapshots of timeline data structures.
Expand Down
Loading

0 comments on commit a454f2a

Please sign in to comment.