Skip to content
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

Apply modernizer plugin to pulsar-client-autn pulsar-websocket and pu… #13398

Merged
merged 1 commit into from
Dec 21, 2021
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
18 changes: 18 additions & 0 deletions pulsar-broker-auth-athenz/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,24 @@

<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>
<phase>verify</phase>
<goals>
<goal>modernizer</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
Expand Down
23 changes: 23 additions & 0 deletions pulsar-broker-auth-sasl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,27 @@
</dependencies>
</profile>
</profiles>


<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>
<phase>verify</phase>
<goals>
<goal>modernizer</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import java.io.IOException;
import java.net.SocketAddress;
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.ConcurrentHashMap;
Expand All @@ -49,7 +50,6 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import org.apache.pulsar.broker.ServiceConfiguration;
import org.apache.pulsar.common.api.AuthData;
Expand All @@ -75,7 +75,7 @@ public class AuthenticationProviderSasl implements AuthenticationProvider {

@Override
public void initialize(ServiceConfiguration config) throws IOException {
this.configuration = Maps.newHashMap();
this.configuration = new HashMap<>();
final String allowedIdsPatternRegExp = config.getSaslJaasClientAllowedIds();
configuration.put(JAAS_CLIENT_ALLOWED_IDS, allowedIdsPatternRegExp);
configuration.put(JAAS_SERVER_SECTION_NAME, config.getSaslJaasServerSectionName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public void setExpires(long expires) {
* Generates the token.
*/
private void generateToken() {
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
sb.append(USER_ROLE).append("=").append(getUserRole()).append(ATTR_SEPARATOR);
sb.append(SESSION).append("=").append(getSession()).append(ATTR_SEPARATOR);
sb.append(EXPIRES).append("=").append(getExpires());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package org.apache.pulsar.broker.authentication;

import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;

import java.io.File;
import java.io.FileWriter;
Expand Down Expand Up @@ -267,7 +266,7 @@ void testAuthentication() throws Exception {
}

Message<byte[]> msg = null;
Set<String> messageSet = Sets.newHashSet();
Set<String> messageSet = new HashSet<>();
for (int i = 0; i < 10; i++) {
msg = consumer.receive(5, TimeUnit.SECONDS);
String receivedMessage = new String(msg.getData());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import javax.security.auth.login.Configuration;

import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;
import org.apache.curator.shaded.com.google.common.collect.Maps;
Expand Down Expand Up @@ -228,7 +227,7 @@ public void testProducerAndConsumerPassed() throws Exception {
}

Message<byte[]> msg = null;
Set<String> messageSet = Sets.newHashSet();
Set<String> messageSet = new HashSet<>();
for (int i = 0; i < 10; i++) {
msg = consumer.receive(5, TimeUnit.SECONDS);
String receivedMessage = new String(msg.getData());
Expand Down
18 changes: 18 additions & 0 deletions pulsar-client-auth-athenz/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,24 @@
</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>
<phase>verify</phase>
<goals>
<goal>modernizer</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
Expand Down
22 changes: 22 additions & 0 deletions pulsar-client-auth-sasl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,26 @@
</dependency>

</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>
<phase>verify</phase>
<goals>
<goal>modernizer</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import java.io.IOException;
import java.net.HttpURLConnection;
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
Expand All @@ -55,7 +56,6 @@
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import com.google.common.collect.Maps;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.pulsar.client.api.Authentication;
Expand Down Expand Up @@ -212,7 +212,7 @@ public Set<Entry<String, String>> newRequestHeader(String hostName,
AuthenticationDataProvider authData,
Map<String, String> previousRespHeaders) throws Exception {

Map<String, String> headers = Maps.newHashMap();
Map<String, String> headers = new HashMap<>();

if (authData.hasDataForHttp()) {
authData.getHttpHeaders().forEach(header ->
Expand Down Expand Up @@ -281,7 +281,7 @@ public Set<Entry<String, String>> newRequestHeader(String hostName,
}

private Map<String, String> getHeaders(Response response) {
Map<String, String> headers = Maps.newHashMap();
Map<String, String> headers = new HashMap<>();
String saslHeader = response.getHeaderString(SASL_HEADER_TYPE);
String headerState = response.getHeaderString(SASL_HEADER_STATE);
String authToken = response.getHeaderString(SASL_AUTH_TOKEN);
Expand Down
22 changes: 22 additions & 0 deletions pulsar-testclient/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,26 @@
</dependencies>
</profile>
</profiles>

<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>
<phase>verify</phase>
<goals>
<goal>modernizer</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand All @@ -45,7 +46,6 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.LongAdder;

import com.google.common.collect.Lists;
import org.apache.commons.lang3.StringUtils;
import org.apache.pulsar.client.api.Authentication;
import org.apache.pulsar.client.api.AuthenticationDataProvider;
Expand Down Expand Up @@ -219,7 +219,7 @@ public void runPerformanceTest(Arguments arguments) throws InterruptedException,
// Read payload data from file if needed
final byte[] payloadBytes = new byte[arguments.msgSize];
Random random = new Random(0);
List<byte[]> payloadByteList = Lists.newArrayList();
List<byte[]> payloadByteList = new ArrayList<>();
if (arguments.payloadFilename != null) {
Path payloadFilePath = Paths.get(arguments.payloadFilename);
if (Files.notExists(payloadFilePath) || Files.size(payloadFilePath) == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.io.PrintStream;
import java.nio.ByteBuffer;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Properties;
Expand Down Expand Up @@ -59,7 +60,6 @@

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.google.common.collect.Lists;
import com.google.common.util.concurrent.RateLimiter;

public class PerformanceConsumer {
Expand Down Expand Up @@ -258,7 +258,7 @@ public static void main(String[] args) throws Exception {
// keep compatibility with the previous version
if (arguments.topic.size() == 1) {
String prefixTopicName = TopicName.get(arguments.topic.get(0)).toString().trim();
List<String> defaultTopics = Lists.newArrayList();
List<String> defaultTopics = new ArrayList<>();
for (int i = 0; i < arguments.numTopics; i++) {
defaultTopics.add(String.format("%s-%d", prefixTopicName, i));
}
Expand All @@ -282,7 +282,7 @@ public static void main(String[] args) throws Exception {
if (arguments.subscriberName == null) {
arguments.subscriberName = arguments.subscriptions.get(0);
}
List<String> defaultSubscriptions = Lists.newArrayList();
List<String> defaultSubscriptions = new ArrayList<>();
for (int i = 0; i < arguments.numSubscriptions; i++) {
defaultSubscriptions.add(String.format("%s-%d", arguments.subscriberName, i));
}
Expand Down Expand Up @@ -477,7 +477,7 @@ public static void main(String[] args) throws Exception {

};

List<Future<Consumer<ByteBuffer>>> futures = Lists.newArrayList();
List<Future<Consumer<ByteBuffer>>> futures = new ArrayList<>();
ConsumerBuilder<ByteBuffer> consumerBuilder = pulsarClient.newConsumer(Schema.BYTEBUFFER) //
.messageListener(listener) //
.receiverQueueSize(arguments.receiverQueueSize) //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import com.beust.jcommander.Parameters;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.google.common.collect.Lists;
import com.google.common.util.concurrent.RateLimiter;

import io.netty.util.concurrent.DefaultThreadFactory;
Expand All @@ -41,6 +40,7 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Properties;
Expand Down Expand Up @@ -312,7 +312,7 @@ public static void main(String[] args) throws Exception {
// keep compatibility with the previous version
if (arguments.topics.size() == 1) {
String prefixTopicName = arguments.topics.get(0);
List<String> defaultTopics = Lists.newArrayList();
List<String> defaultTopics = new ArrayList<>();
for (int i = 0; i < arguments.numTopics; i++) {
defaultTopics.add(String.format("%s%s%d", prefixTopicName, arguments.separator, i));
}
Expand Down Expand Up @@ -377,7 +377,7 @@ public static void main(String[] args) throws Exception {
// Read payload data from file if needed
final byte[] payloadBytes = new byte[arguments.msgSize];
Random random = new Random(0);
List<byte[]> payloadByteList = Lists.newArrayList();
List<byte[]> payloadByteList = new ArrayList<>();
if (arguments.payloadFilename != null) {
Path payloadFilePath = Paths.get(arguments.payloadFilename);
if (Files.notExists(payloadFilePath) || Files.size(payloadFilePath) == 0) {
Expand Down Expand Up @@ -557,7 +557,7 @@ private static void runProducer(int producerId,
PulsarClient client = null;
try {
// Now processing command line arguments
List<Future<Producer<byte[]>>> futures = Lists.newArrayList();
List<Future<Producer<byte[]>>> futures = new ArrayList<>();

ClientBuilder clientBuilder = PulsarClient.builder() //
.enableTransaction(arguments.isEnableTransaction)//
Expand Down Expand Up @@ -641,7 +641,7 @@ private static void runProducer(int producerId,
}
}

final List<Producer<byte[]>> producers = Lists.newArrayListWithCapacity(futures.size());
final List<Producer<byte[]>> producers = new ArrayList<>(futures.size());
for (Future<Producer<byte[]>> future : futures) {
producers.add(future.get());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
import com.beust.jcommander.Parameters;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.google.common.collect.Lists;
import com.google.common.util.concurrent.RateLimiter;
import java.io.FileInputStream;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import java.util.concurrent.CompletableFuture;
Expand Down Expand Up @@ -162,7 +162,7 @@ public static void main(String[] args) throws Exception {
// keep compatibility with the previous version
if (arguments.topic.size() == 1) {
String prefixTopicName = arguments.topic.get(0);
List<String> defaultTopics = Lists.newArrayList();
List<String> defaultTopics = new ArrayList<>();
for (int i = 0; i < arguments.numTopics; i++) {
defaultTopics.add(String.format("%s-%d", prefixTopicName, i));
}
Expand Down Expand Up @@ -273,7 +273,7 @@ public static void main(String[] args) throws Exception {

PulsarClient pulsarClient = clientBuilder.build();

List<CompletableFuture<Reader<byte[]>>> futures = Lists.newArrayList();
List<CompletableFuture<Reader<byte[]>>> futures = new ArrayList<>();

MessageId startMessageId;
if ("earliest".equals(arguments.startMessageId)) {
Expand Down
Loading