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

[Issue 12271][Modernizer] Add Maven Modernizer plugin in pulsar-proxy module #12326

Merged
merged 1 commit into from
Oct 25, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ flexible messaging model and an intuitive client API.</description>
<j2objc-annotations.version>1.3</j2objc-annotations.version>
<lightproto-maven-plugin.version>0.4</lightproto-maven-plugin.version>
<dependency-check-maven.version>6.1.6</dependency-check-maven.version>
<modernizer-maven-plugin.version>2.3.0</modernizer-maven-plugin.version>

<!-- Used to configure rename.netty.native. Libs -->
<rename.netty.native.libs>rename-netty-native-libs.sh</rename.netty.native.libs>
Expand Down
21 changes: 21 additions & 0 deletions pulsar-proxy/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,27 @@
<artifactId>log4j-core</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.gaul</groupId>
<artifactId>modernizer-maven-plugin</artifactId>
<version>${modernizer-maven-plugin.version}</version>
<configuration>
<failOnViolations>true</failOnViolations>
<javaVersion>8</javaVersion>
</configuration>
<executions>
<execution>
<id>modernizer</id>
<goals>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<phase>verify</phase> was missing here. Added in #13168

<goal>modernizer</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<!-- enables builds with -Dmaven.test.skip=true -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
package org.apache.pulsar.proxy.extensions;

import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import java.util.HashMap;
import java.util.HashSet;
import lombok.extern.slf4j.Slf4j;
import org.apache.pulsar.proxy.server.ProxyConfiguration;
import org.apache.pulsar.proxy.server.ProxyService;
Expand Down Expand Up @@ -108,8 +108,8 @@ public void initialize(ProxyConfiguration conf) throws Exception {
}

public Map<String, Map<InetSocketAddress, ChannelInitializer<SocketChannel>>> newChannelInitializers() {
Map<String, Map<InetSocketAddress, ChannelInitializer<SocketChannel>>> channelInitializers = Maps.newHashMap();
Set<InetSocketAddress> addresses = Sets.newHashSet();
Map<String, Map<InetSocketAddress, ChannelInitializer<SocketChannel>>> channelInitializers = new HashMap<>();
Set<InetSocketAddress> addresses = new HashSet<>();

for (Map.Entry<String, ProxyExtensionWithClassLoader> extension : extensions.entrySet()) {
Map<InetSocketAddress, ChannelInitializer<SocketChannel>> initializers =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package org.apache.pulsar.proxy.server;

import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
Expand All @@ -33,8 +34,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.collect.Lists;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufUtil;
import io.netty.buffer.CompositeByteBuf;
Expand Down Expand Up @@ -96,7 +95,7 @@ private void logging(Channel conn, BaseCommand.Type cmdtype, String info, List<R

public void channelRead(ChannelHandlerContext ctx, Object msg) {
TopicName topicName ;
List<RawMessage> messages = Lists.newArrayList();
List<RawMessage> messages = new ArrayList<>();
ByteBuf buffer = (ByteBuf)(msg);

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
*/
package org.apache.pulsar.proxy.server;

import com.google.common.collect.Sets;

import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Properties;
import java.util.Set;
import java.util.TreeSet;
import java.util.stream.Collectors;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -203,7 +203,7 @@ public class ProxyConfiguration implements PulsarConfiguration {
+ " `super-user`, meaning they will be able to do all admin operations and publish"
+ " & consume from all topics"
)
private Set<String> superUserRoles = Sets.newTreeSet();
private Set<String> superUserRoles = new TreeSet<>();

@FieldContext(
category = CATEGORY_AUTHENTICATION,
Expand All @@ -214,7 +214,7 @@ public class ProxyConfiguration implements PulsarConfiguration {
category = CATEGORY_AUTHENTICATION,
doc = "Authentication provider name list (a comma-separated list of class names"
)
private Set<String> authenticationProviders = Sets.newTreeSet();
private Set<String> authenticationProviders = new TreeSet<>();
@FieldContext(
category = CATEGORY_AUTHORIZATION,
doc = "Whether authorization is enforced by the Pulsar proxy"
Expand Down Expand Up @@ -346,14 +346,14 @@ public class ProxyConfiguration implements PulsarConfiguration {
+ " (a comma-separated list of protocol names).\n\n"
+ "Examples:- [TLSv1.3, TLSv1.2]"
)
private Set<String> tlsProtocols = Sets.newTreeSet();
private Set<String> tlsProtocols = new TreeSet<>();
@FieldContext(
category = CATEGORY_TLS,
doc = "Specify the tls cipher the proxy will use to negotiate during TLS Handshake"
+ " (a comma-separated list of ciphers).\n\n"
+ "Examples:- [TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256]"
)
private Set<String> tlsCiphers = Sets.newTreeSet();
private Set<String> tlsCiphers = new TreeSet<>();
@FieldContext(
category = CATEGORY_TLS,
doc = "Whether client certificates are required for TLS.\n\n"
Expand Down Expand Up @@ -449,23 +449,23 @@ public class ProxyConfiguration implements PulsarConfiguration {
+ "Examples:- [TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256].\n"
+ " used by the Pulsar proxy to authenticate with Pulsar brokers"
)
private Set<String> brokerClientTlsCiphers = Sets.newTreeSet();
private Set<String> brokerClientTlsCiphers = new TreeSet<>();
@FieldContext(
category = CATEGORY_KEYSTORE_TLS,
doc = "Specify the tls protocols the broker will use to negotiate during TLS handshake"
+ " (a comma-separated list of protocol names).\n\n"
+ "Examples:- [TLSv1.3, TLSv1.2] \n"
+ " used by the Pulsar proxy to authenticate with Pulsar brokers"
)
private Set<String> brokerClientTlsProtocols = Sets.newTreeSet();
private Set<String> brokerClientTlsProtocols = new TreeSet<>();

/***** --- HTTP --- ****/

@FieldContext(
category = CATEGORY_HTTP,
doc = "Http directs to redirect to non-pulsar services"
)
private Set<HttpReverseProxyConfig> httpReverseProxyConfigs = Sets.newHashSet();
private Set<HttpReverseProxyConfig> httpReverseProxyConfigs = new HashSet<>();

@FieldContext(
minValue = 1,
Expand Down Expand Up @@ -523,13 +523,13 @@ public class ProxyConfiguration implements PulsarConfiguration {
category = CATEGORY_PLUGIN,
doc = "List of proxy additional servlet to load, which is a list of proxy additional servlet names"
)
private Set<String> proxyAdditionalServlets = Sets.newTreeSet();
private Set<String> proxyAdditionalServlets = new TreeSet<>();

@FieldContext(
category = CATEGORY_PLUGIN,
doc = "List of proxy additional servlet to load, which is a list of proxy additional servlet names"
)
private Set<String> additionalServlets = Sets.newTreeSet();
private Set<String> additionalServlets = new TreeSet<>();

@FieldContext(
category = CATEGORY_HTTP,
Expand Down Expand Up @@ -579,7 +579,7 @@ public class ProxyConfiguration implements PulsarConfiguration {
category = CATEGORY_PLUGIN,
doc = "List of messaging protocols to load, which is a list of extension names"
)
private Set<String> proxyExtensions = Sets.newTreeSet();
private Set<String> proxyExtensions = new TreeSet<>();

/***** --- WebSocket --- ****/
@FieldContext(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@
*/
package org.apache.pulsar.proxy.server;

import static com.google.common.base.Preconditions.checkNotNull;
import static java.util.Objects.requireNonNull;
import static org.apache.commons.lang3.StringUtils.isBlank;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.AdaptiveRecvByteBufAllocator;
Expand All @@ -41,6 +40,7 @@
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.Semaphore;
Expand Down Expand Up @@ -131,11 +131,11 @@ public class ProxyService implements Closeable {

public ProxyService(ProxyConfiguration proxyConfig,
AuthenticationService authenticationService) throws Exception {
checkNotNull(proxyConfig);
requireNonNull(proxyConfig);
this.proxyConfig = proxyConfig;
this.timer = new HashedWheelTimer(new DefaultThreadFactory("pulsar-timer", Thread.currentThread().isDaemon()), 1, TimeUnit.MILLISECONDS);
this.clientCnxs = Sets.newConcurrentHashSet();
this.topicStats = Maps.newConcurrentMap();
this.topicStats = new ConcurrentHashMap<>();

this.lookupRequestSemaphore = new AtomicReference<Semaphore>(
new Semaphore(proxyConfig.getMaxConcurrentLookupRequests(), false));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
*/
package org.apache.pulsar.proxy.server;

import com.google.common.collect.Lists;

import io.prometheus.client.jetty.JettyStatisticsCollector;
import java.io.IOException;
import java.net.URI;
Expand Down Expand Up @@ -69,8 +67,8 @@ public class WebServer {
private final Server server;
private final WebExecutorThreadPool webServiceExecutor;
private final AuthenticationService authenticationService;
private final List<String> servletPaths = Lists.newArrayList();
private final List<Handler> handlers = Lists.newArrayList();
private final List<String> servletPaths = new ArrayList<>();
private final List<Handler> handlers = new ArrayList<>();
private final ProxyConfiguration config;
protected int externalServicePort;
private URI serviceURI = null;
Expand All @@ -84,7 +82,7 @@ public WebServer(ProxyConfiguration config, AuthenticationService authentication
this.authenticationService = authenticationService;
this.config = config;

List<ServerConnector> connectors = Lists.newArrayList();
List<ServerConnector> connectors = new ArrayList<>();

HttpConfiguration http_config = new HttpConfiguration();
http_config.setOutputBufferSize(config.getHttpOutputBufferSize());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package org.apache.pulsar.proxy.stats;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
Expand All @@ -34,8 +35,6 @@

import org.apache.pulsar.proxy.server.ProxyService;

import com.google.common.collect.Lists;

import io.netty.channel.Channel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
Expand All @@ -59,7 +58,7 @@ public class ProxyStats {
@ApiOperation(value = "Proxy stats api to get info for live connections", response = List.class, responseContainer = "List")
@ApiResponses(value = { @ApiResponse(code = 503, message = "Proxy service is not initialized") })
public List<ConnectionStats> metrics() {
List<ConnectionStats> stats = Lists.newArrayList();
List<ConnectionStats> stats = new ArrayList<>();
proxyService().getClientCnxs().forEach(cnx -> {
if (cnx.getDirectProxyHandler() == null) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public void testTlsSyncProducerAndConsumer() throws Exception {
}

Message<byte[]> msg = null;
Set<String> messageSet = Sets.newHashSet();
Set<String> messageSet = new HashSet<>();
int count = 0;
for (int i = 0; i < 10; i++) {
msg = consumer.receive(5, TimeUnit.SECONDS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
package org.apache.pulsar.proxy.server;

import static com.google.common.base.Preconditions.checkNotNull;
import static java.util.Objects.requireNonNull;
import static org.mockito.Mockito.doReturn;

import com.google.common.collect.Sets;
Expand Down Expand Up @@ -195,7 +195,7 @@ public void testPartitions() throws Exception {

for (int i = 0; i < 10; i++) {
Message<byte[]> msg = consumer.receive(1, TimeUnit.SECONDS);
checkNotNull(msg);
requireNonNull(msg);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
package org.apache.pulsar.proxy.server;

import static com.google.common.base.Preconditions.checkNotNull;
import static java.util.Objects.requireNonNull;
import static org.mockito.Mockito.doReturn;

import java.util.HashMap;
Expand Down Expand Up @@ -180,7 +180,7 @@ public void testPartitions() throws Exception {

for (int i = 0; i < 10; i++) {
Message<byte[]> msg = consumer.receive(1, TimeUnit.SECONDS);
checkNotNull(msg);
requireNonNull(msg);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
package org.apache.pulsar.proxy.server;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.Objects.requireNonNull;
import static org.mockito.Mockito.doReturn;
import static org.testng.Assert.assertEquals;

Expand Down Expand Up @@ -128,7 +128,7 @@ public void testProducerConsumer() throws Exception {

for (int i = 0; i < 10; i++) {
Message<byte[]> msg = consumer.receive(1, TimeUnit.SECONDS);
checkNotNull(msg);
requireNonNull(msg);
consumer.acknowledge(msg);
}

Expand Down Expand Up @@ -162,7 +162,7 @@ public void testPartitions() throws Exception {

for (int i = 0; i < 10; i++) {
Message<byte[]> msg = consumer.receive(1, TimeUnit.SECONDS);
checkNotNull(msg);
requireNonNull(msg);
}
}

Expand Down Expand Up @@ -231,7 +231,7 @@ public void testProtocolVersionAdvertisement() throws Exception {

for (int i = 0; i < 10; i++) {
Message<byte[]> msg = consumer.receive(10, TimeUnit.SECONDS);
checkNotNull(msg);
requireNonNull(msg);
consumer.acknowledge(msg);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
package org.apache.pulsar.proxy.server;

import static com.google.common.base.Preconditions.checkNotNull;
import static java.util.Objects.requireNonNull;
import static org.mockito.Mockito.doReturn;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
Expand Down Expand Up @@ -120,7 +120,7 @@ public void testConnectionsStats() throws Exception {

for (int i = 0; i < totalMessages; i++) {
Message<byte[]> msg = consumer.receive(1, TimeUnit.SECONDS);
checkNotNull(msg);
requireNonNull(msg);
consumer.acknowledge(msg);
}

Expand Down Expand Up @@ -169,7 +169,7 @@ public void testTopicStats() throws Exception {

for (int i = 0; i < totalMessages; i++) {
Message<byte[]> msg = consumer.receive(1, TimeUnit.SECONDS);
checkNotNull(msg);
requireNonNull(msg);
consumer.acknowledge(msg);
msg = consumer2.receive(1, TimeUnit.SECONDS);
}
Expand Down