Skip to content

Commit

Permalink
Apply modernizer plugin to pulsar-client modules. (apache#12971)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvinCai authored Nov 29, 2021
1 parent 2b57373 commit 656398e
Show file tree
Hide file tree
Showing 42 changed files with 216 additions and 108 deletions.
17 changes: 17 additions & 0 deletions pulsar-client-1x-base/pulsar-client-1x/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,23 @@

<build>
<plugins>
<plugin>
<groupId>org.gaul</groupId>
<artifactId>modernizer-maven-plugin</artifactId>
<configuration>
<failOnViolations>true</failOnViolations>
<javaVersion>8</javaVersion>
</configuration>
<executions>
<execution>
<id>modernizer</id>
<goals>
<goal>modernizer</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
package org.apache.pulsar.client.api;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;

import java.io.Serializable;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.TimeUnit;

import org.apache.pulsar.client.impl.conf.ConsumerConfigurationData;
Expand Down Expand Up @@ -94,7 +94,7 @@ public SubscriptionType getSubscriptionType() {
* the subscription type value
*/
public ConsumerConfiguration setSubscriptionType(SubscriptionType subscriptionType) {
checkNotNull(subscriptionType);
Objects.requireNonNull(subscriptionType);
conf.setSubscriptionType(subscriptionType);
return this;
}
Expand All @@ -116,7 +116,7 @@ public MessageListener<byte[]> getMessageListener() {
* the listener object
*/
public ConsumerConfiguration setMessageListener(MessageListener<byte[]> messageListener) {
checkNotNull(messageListener);
Objects.requireNonNull(messageListener);
this.messageListener = messageListener;
conf.setMessageListener(new org.apache.pulsar.shade.client.api.v2.MessageListener<byte[]>() {

Expand Down Expand Up @@ -158,7 +158,7 @@ public ConsumerEventListener getConsumerEventListener() {
* @since 2.0
*/
public ConsumerConfiguration setConsumerEventListener(ConsumerEventListener listener) {
checkNotNull(listener);
Objects.requireNonNull(listener);
conf.setConsumerEventListener(listener);
return this;
}
Expand Down Expand Up @@ -204,7 +204,7 @@ public CryptoKeyReader getCryptoKeyReader() {
* CryptoKeyReader object
*/
public ConsumerConfiguration setCryptoKeyReader(CryptoKeyReader cryptoKeyReader) {
checkNotNull(cryptoKeyReader);
Objects.requireNonNull(cryptoKeyReader);
conf.setCryptoKeyReader(cryptoKeyReader);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
package org.apache.pulsar.client.api;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;

import java.io.Serializable;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -188,7 +188,7 @@ public ProducerConfiguration setBlockIfQueueFull(boolean blockIfQueueFull) {
* @see MessageRoutingMode
*/
public ProducerConfiguration setMessageRoutingMode(MessageRoutingMode messageRouteMode) {
checkNotNull(messageRouteMode);
Objects.requireNonNull(messageRouteMode);
conf.setMessageRoutingMode(
org.apache.pulsar.client.api.MessageRoutingMode.valueOf(messageRouteMode.toString()));
return this;
Expand Down Expand Up @@ -239,7 +239,7 @@ public CompressionType getCompressionType() {
* @param messageRouter
*/
public ProducerConfiguration setMessageRouter(MessageRouter messageRouter) {
checkNotNull(messageRouter);
Objects.requireNonNull(messageRouter);
setMessageRoutingMode(MessageRoutingMode.CustomPartition);
conf.setCustomMessageRouter(messageRouter);
return this;
Expand Down Expand Up @@ -313,7 +313,7 @@ public CryptoKeyReader getCryptoKeyReader() {
* CryptoKeyReader object
*/
public ProducerConfiguration setCryptoKeyReader(CryptoKeyReader cryptoKeyReader) {
checkNotNull(cryptoKeyReader);
Objects.requireNonNull(cryptoKeyReader);
conf.setCryptoKeyReader(cryptoKeyReader);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
import org.apache.commons.lang3.StringUtils;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;

import java.io.Serializable;
import java.util.Objects;

import org.apache.pulsar.client.impl.conf.ReaderConfigurationData;
import org.apache.pulsar.client.impl.v1.ReaderV1Impl;
Expand Down Expand Up @@ -56,7 +56,7 @@ public ReaderListener<byte[]> getReaderListener() {
* the listener object
*/
public ReaderConfiguration setReaderListener(ReaderListener<byte[]> readerListener) {
checkNotNull(readerListener);
Objects.requireNonNull(readerListener);
this.readerListener = readerListener;
conf.setReaderListener(new org.apache.pulsar.shade.client.api.v2.ReaderListener<byte[]>() {

Expand Down Expand Up @@ -94,7 +94,7 @@ public CryptoKeyReader getCryptoKeyReader() {
* CryptoKeyReader object
*/
public ReaderConfiguration setCryptoKeyReader(CryptoKeyReader cryptoKeyReader) {
checkNotNull(cryptoKeyReader);
Objects.requireNonNull(cryptoKeyReader);
conf.setCryptoKeyReader(cryptoKeyReader);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@

import static com.google.common.base.Preconditions.checkArgument;

import com.google.common.base.Preconditions;

import java.nio.ByteBuffer;
import java.util.List;
import java.util.Map;
import java.util.Objects;

import org.apache.pulsar.client.api.Message;
import org.apache.pulsar.client.api.MessageBuilder;
Expand Down Expand Up @@ -101,7 +100,7 @@ public MessageBuilder setSequenceId(long sequenceId) {

@Override
public MessageBuilder setReplicationClusters(List<String> clusters) {
Preconditions.checkNotNull(clusters);
Objects.requireNonNull(clusters);
msgMetadataBuilder.clearReplicateTo();
msgMetadataBuilder.addAllReplicateTos(clusters);
return this;
Expand Down
17 changes: 17 additions & 0 deletions pulsar-client-admin-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,23 @@

<build>
<plugins>
<plugin>
<groupId>org.gaul</groupId>
<artifactId>modernizer-maven-plugin</artifactId>
<configuration>
<failOnViolations>true</failOnViolations>
<javaVersion>8</javaVersion>
</configuration>
<executions>
<execution>
<id>modernizer</id>
<goals>
<goal>modernizer</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
Expand Down
17 changes: 17 additions & 0 deletions pulsar-client-admin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,23 @@

<build>
<plugins>
<plugin>
<groupId>org.gaul</groupId>
<artifactId>modernizer-maven-plugin</artifactId>
<configuration>
<failOnViolations>true</failOnViolations>
<javaVersion>8</javaVersion>
</configuration>
<executions>
<execution>
<id>modernizer</id>
<goals>
<goal>modernizer</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
package org.apache.pulsar.client.admin.internal;

import static com.google.common.base.Preconditions.checkArgument;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.io.InputStream;
Expand All @@ -31,6 +29,7 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -1145,7 +1144,7 @@ public List<Message<byte[]>> peekMessages(String topic, String subName, int numM
public CompletableFuture<List<Message<byte[]>>> peekMessagesAsync(String topic, String subName, int numMessages) {
checkArgument(numMessages > 0);
CompletableFuture<List<Message<byte[]>>> future = new CompletableFuture<List<Message<byte[]>>>();
peekMessagesAsync(topic, subName, numMessages, Lists.newArrayList(), future, 1);
peekMessagesAsync(topic, subName, numMessages, new ArrayList<>(), future, 1);
return future;
}

Expand Down Expand Up @@ -1615,7 +1614,7 @@ private List<Message<byte[]>> getMessagesFromHttpResponse(String topic, Response
byte[] data = new byte[stream.available()];
stream.read(data);

Map<String, String> properties = Maps.newTreeMap();
Map<String, String> properties = new TreeMap<>();
MultivaluedMap<String, Object> headers = response.getHeaders();
Object tmp = headers.getFirst(PUBLISH_TIME);
if (tmp != null) {
Expand Down
17 changes: 17 additions & 0 deletions pulsar-client-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,23 @@

<build>
<plugins>
<plugin>
<groupId>org.gaul</groupId>
<artifactId>modernizer-maven-plugin</artifactId>
<configuration>
<failOnViolations>true</failOnViolations>
<javaVersion>8</javaVersion>
</configuration>
<executions>
<execution>
<id>modernizer</id>
<goals>
<goal>modernizer</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
Expand Down
17 changes: 17 additions & 0 deletions pulsar-client-tools-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,23 @@
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.gaul</groupId>
<artifactId>modernizer-maven-plugin</artifactId>
<configuration>
<failOnViolations>true</failOnViolations>
<javaVersion>8</javaVersion>
</configuration>
<executions>
<execution>
<id>modernizer</id>
<goals>
<goal>modernizer</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;

import java.io.File;
Expand All @@ -40,6 +39,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.CompletableFuture;
Expand Down Expand Up @@ -1513,7 +1513,7 @@ public void testAuthTlsWithJsonParam() throws Exception {

Properties properties = new Properties();
properties.put("authPlugin", AuthenticationTls.class.getName());
Map<String, String> paramMap = Maps.newHashMap();
Map<String, String> paramMap = new HashMap<>();
final String certFilePath = "/my-file:role=name.cert";
final String keyFilePath = "/my-file:role=name.key";
paramMap.put("tlsCertFile", certFilePath);
Expand Down
17 changes: 17 additions & 0 deletions pulsar-client-tools/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,23 @@

<build>
<plugins>
<plugin>
<groupId>org.gaul</groupId>
<artifactId>modernizer-maven-plugin</artifactId>
<configuration>
<failOnViolations>true</failOnViolations>
<javaVersion>8</javaVersion>
</configuration>
<executions>
<execution>
<id>modernizer</id>
<goals>
<goal>modernizer</goal>
</goals>
</execution>
</executions>
</plugin>

<!-- this task is used for copy all python files together to provide a instance directory
for running python instance -->
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;

import org.apache.pulsar.client.admin.PulsarAdminException;
import org.apache.pulsar.client.api.MessageId;
Expand All @@ -36,7 +37,6 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.google.common.base.Preconditions;
import com.google.common.collect.Sets;

abstract class CliCommand {

Expand Down Expand Up @@ -167,7 +167,7 @@ static String getOneArgument(List<String> params, int pos, int maxArguments) {
}

static Set<AuthAction> getAuthActions(List<String> actions) {
Set<AuthAction> res = Sets.newTreeSet();
Set<AuthAction> res = new TreeSet<>();
AuthAction authAction;
for (String action : actions) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2204,7 +2204,7 @@ void run() throws PulsarAdminException {
long maxBlockSize = validateSizeString(maxBlockSizeStr);
if (positiveCheck("MaxBlockSize", maxBlockSize)
&& maxValueCheck("MaxBlockSize", maxBlockSize, Integer.MAX_VALUE)) {
maxBlockSizeInBytes = new Long(maxBlockSize).intValue();
maxBlockSizeInBytes = Long.valueOf(maxBlockSize).intValue();
}
}

Expand All @@ -2213,7 +2213,7 @@ && maxValueCheck("MaxBlockSize", maxBlockSize, Integer.MAX_VALUE)) {
long readBufferSize = validateSizeString(readBufferSizeStr);
if (positiveCheck("ReadBufferSize", readBufferSize)
&& maxValueCheck("ReadBufferSize", readBufferSize, Integer.MAX_VALUE)) {
readBufferSizeInBytes = new Long(readBufferSize).intValue();
readBufferSizeInBytes = Long.valueOf(readBufferSize).intValue();
}
}

Expand Down
Loading

0 comments on commit 656398e

Please sign in to comment.