You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by xx...@apache.org on 2022/08/26 00:37:16 UTC
[pulsar] branch master updated: [Improvement] Apply maven modernizer to remaining modules. (#17193)
This is an automated email from the ASF dual-hosted git repository.
xxc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/master by this push:
new daeddb5900c [Improvement] Apply maven modernizer to remaining modules. (#17193)
daeddb5900c is described below
commit daeddb5900c4e09e42986563aedc800986243f25
Author: Marvin Cai <ca...@gmail.com>
AuthorDate: Thu Aug 25 17:36:59 2022 -0700
[Improvement] Apply maven modernizer to remaining modules. (#17193)
Applied to following modeules:
pulsar-config-validation
pulsar-functions
pulsar-metadata
pulsar-package-management
---
pulsar-config-validation/pom.xml | 18 ++++++++++++++++++
pulsar-functions/instance/pom.xml | 18 ++++++++++++++++++
.../functions/instance/JavaInstanceRunnable.java | 4 ++--
pulsar-functions/runtime/pom.xml | 18 ++++++++++++++++++
.../apache/pulsar/functions/worker/WorkerConfig.java | 5 ++---
pulsar-functions/secrets/pom.xml | 18 ++++++++++++++++++
pulsar-functions/utils/pom.xml | 18 ++++++++++++++++++
pulsar-functions/worker/pom.xml | 18 ++++++++++++++++++
.../pulsar/functions/worker/SchedulerManager.java | 15 +++++++--------
.../functions/worker/rest/api/ComponentImpl.java | 4 ++--
.../pulsar/functions/worker/rest/api/WorkerImpl.java | 4 ++--
.../worker/scheduler/RoundRobinScheduler.java | 4 ++--
.../functions/worker/FunctionRuntimeManagerTest.java | 3 +--
.../pulsar/functions/worker/SchedulerManagerTest.java | 12 ++++++------
.../functions/worker/dlog/DLInputStreamTest.java | 5 +++--
.../worker/executor/MockExecutorController.java | 6 +++---
pulsar-metadata/pom.xml | 18 ++++++++++++++++++
pulsar-package-management/core/pom.xml | 18 ++++++++++++++++++
18 files changed, 174 insertions(+), 32 deletions(-)
diff --git a/pulsar-config-validation/pom.xml b/pulsar-config-validation/pom.xml
index 2c72b566c51..48d7a7fb57c 100644
--- a/pulsar-config-validation/pom.xml
+++ b/pulsar-config-validation/pom.xml
@@ -42,6 +42,24 @@
<build>
<plugins>
+ <plugin>
+ <groupId>org.gaul</groupId>
+ <artifactId>modernizer-maven-plugin</artifactId>
+ <configuration>
+ <failOnViolations>true</failOnViolations>
+ <javaVersion>17</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>
diff --git a/pulsar-functions/instance/pom.xml b/pulsar-functions/instance/pom.xml
index 04524d9d714..2410142570f 100644
--- a/pulsar-functions/instance/pom.xml
+++ b/pulsar-functions/instance/pom.xml
@@ -204,6 +204,24 @@
<build>
<plugins>
+ <plugin>
+ <groupId>org.gaul</groupId>
+ <artifactId>modernizer-maven-plugin</artifactId>
+ <configuration>
+ <failOnViolations>true</failOnViolations>
+ <javaVersion>17</javaVersion>
+ </configuration>
+ <executions>
+ <execution>
+ <id>modernizer</id>
+ <phase>verify</phase>
+ <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>
diff --git a/pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/instance/JavaInstanceRunnable.java b/pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/instance/JavaInstanceRunnable.java
index 7429156ca50..11e443e72e0 100644
--- a/pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/instance/JavaInstanceRunnable.java
+++ b/pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/instance/JavaInstanceRunnable.java
@@ -18,7 +18,6 @@
*/
package org.apache.pulsar.functions.instance;
-import static com.google.common.base.Preconditions.checkNotNull;
import static org.apache.pulsar.functions.utils.FunctionCommon.convertFromFunctionDetailsSubscriptionPosition;
import com.fasterxml.jackson.core.type.TypeReference;
import com.google.common.annotations.VisibleForTesting;
@@ -26,6 +25,7 @@ import com.scurrilous.circe.checksum.Crc32cIntChecksum;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
+import java.util.Objects;
import java.util.TreeMap;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
@@ -728,7 +728,7 @@ public class JavaInstanceRunnable implements AutoCloseable, Runnable {
convertFromFunctionDetailsSubscriptionPosition(sourceSpec.getSubscriptionPosition())
);
- checkNotNull(contextImpl.getSubscriptionType());
+ Objects.requireNonNull(contextImpl.getSubscriptionType());
pulsarSourceConfig.setSubscriptionType(contextImpl.getSubscriptionType());
pulsarSourceConfig.setTypeClassName(sourceSpec.getTypeClassName());
diff --git a/pulsar-functions/runtime/pom.xml b/pulsar-functions/runtime/pom.xml
index f1bf3abccee..73ebc8eb43e 100644
--- a/pulsar-functions/runtime/pom.xml
+++ b/pulsar-functions/runtime/pom.xml
@@ -75,6 +75,24 @@
<build>
<plugins>
+ <plugin>
+ <groupId>org.gaul</groupId>
+ <artifactId>modernizer-maven-plugin</artifactId>
+ <configuration>
+ <failOnViolations>true</failOnViolations>
+ <javaVersion>17</javaVersion>
+ </configuration>
+ <executions>
+ <execution>
+ <id>modernizer</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>modernizer</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
<!-- this task will copy config files to resources for the test to work -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
diff --git a/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/worker/WorkerConfig.java b/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/worker/WorkerConfig.java
index 8363f1313b9..e7630f7c463 100644
--- a/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/worker/WorkerConfig.java
+++ b/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/worker/WorkerConfig.java
@@ -22,7 +22,6 @@ import static org.apache.commons.lang3.StringUtils.isBlank;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
-import com.google.common.collect.Sets;
import java.io.File;
import java.io.IOException;
import java.io.Serializable;
@@ -533,7 +532,7 @@ public class WorkerConfig implements Serializable, PulsarConfiguration {
category = CATEGORY_WORKER_SECURITY,
doc = "Authentication provider name list, which is a list of class names"
)
- private Set<String> authenticationProviders = Sets.newTreeSet();
+ private Set<String> authenticationProviders = new TreeSet<>();
@FieldContext(
category = CATEGORY_WORKER_SECURITY,
doc = "Enforce authorization on accessing functions admin-api"
@@ -548,7 +547,7 @@ public class WorkerConfig implements Serializable, PulsarConfiguration {
category = CATEGORY_WORKER_SECURITY,
doc = "Role names that are treated as `super-user`, meaning they will be able to access any admin-api"
)
- private Set<String> superUserRoles = Sets.newTreeSet();
+ private Set<String> superUserRoles = new TreeSet<>();
@FieldContext(
category = CATEGORY_WORKER_SECURITY,
diff --git a/pulsar-functions/secrets/pom.xml b/pulsar-functions/secrets/pom.xml
index e2fb651ad2f..55f8ede1f75 100644
--- a/pulsar-functions/secrets/pom.xml
+++ b/pulsar-functions/secrets/pom.xml
@@ -45,6 +45,24 @@
</dependencies>
<build>
<plugins>
+ <plugin>
+ <groupId>org.gaul</groupId>
+ <artifactId>modernizer-maven-plugin</artifactId>
+ <configuration>
+ <failOnViolations>true</failOnViolations>
+ <javaVersion>17</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>
diff --git a/pulsar-functions/utils/pom.xml b/pulsar-functions/utils/pom.xml
index 46e8d077ce8..46ec4910002 100644
--- a/pulsar-functions/utils/pom.xml
+++ b/pulsar-functions/utils/pom.xml
@@ -102,6 +102,24 @@
</dependencies>
<build>
<plugins>
+ <plugin>
+ <groupId>org.gaul</groupId>
+ <artifactId>modernizer-maven-plugin</artifactId>
+ <configuration>
+ <failOnViolations>true</failOnViolations>
+ <javaVersion>17</javaVersion>
+ </configuration>
+ <executions>
+ <execution>
+ <id>modernizer</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>modernizer</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
diff --git a/pulsar-functions/worker/pom.xml b/pulsar-functions/worker/pom.xml
index bead0bd2f1b..c5506244db1 100644
--- a/pulsar-functions/worker/pom.xml
+++ b/pulsar-functions/worker/pom.xml
@@ -187,6 +187,24 @@
<build>
<plugins>
+ <plugin>
+ <groupId>org.gaul</groupId>
+ <artifactId>modernizer-maven-plugin</artifactId>
+ <configuration>
+ <failOnViolations>true</failOnViolations>
+ <javaVersion>17</javaVersion>
+ </configuration>
+ <executions>
+ <execution>
+ <id>modernizer</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>modernizer</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
diff --git a/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/SchedulerManager.java b/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/SchedulerManager.java
index af633ca2e9b..1f4b7852fe2 100644
--- a/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/SchedulerManager.java
+++ b/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/SchedulerManager.java
@@ -18,12 +18,10 @@
*/
package org.apache.pulsar.functions.worker;
-import static com.google.common.base.Preconditions.checkNotNull;
import static java.util.concurrent.TimeUnit.NANOSECONDS;
import static org.apache.pulsar.common.util.Runnables.catchingAndLoggingThrowables;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.collect.Lists;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import io.netty.util.concurrent.DefaultThreadFactory;
import java.util.ArrayList;
@@ -32,6 +30,7 @@ import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
@@ -272,7 +271,7 @@ public class SchedulerManager implements AutoCloseable {
}
// A worker must be specified at this point. This would be set up by the caller.
- checkNotNull(workerId);
+ Objects.requireNonNull(workerId);
// [We can get stricter, and require that every drain op be followed up with a cleanup of the
// corresponding worker before any other drain op, so that the drainOpStatusMap should be empty
@@ -714,7 +713,7 @@ public class SchedulerManager implements AutoCloseable {
Map<String, Map<String, Assignment>> currentAssignments, Map<String, Function.Instance> functionInstances) {
List<Function.Instance> unassignedFunctionInstances = new LinkedList<>();
- List<Assignment> heartBeatAssignments = Lists.newArrayList();
+ List<Assignment> heartBeatAssignments = new ArrayList<>();
Map<String, Assignment> assignmentMap = new HashMap<>();
if (currentAssignments != null) {
for (Map<String, Assignment> entry : currentAssignments.values()) {
@@ -845,7 +844,7 @@ public class SchedulerManager implements AutoCloseable {
public void removedAssignment(Assignment assignment) {
String workerId = assignment.getWorkerId();
WorkerStats stats = workerStatsMap.get(workerId);
- checkNotNull(stats);
+ Objects.requireNonNull(stats);
stats.instancesRemoved++;
stats.finalNumAssignments--;
@@ -857,14 +856,14 @@ public class SchedulerManager implements AutoCloseable {
String oldWorkerId = instanceToWorkerId.get(fullyQualifiedInstanceId);
if (oldWorkerId != null) {
WorkerStats oldWorkerStats = workerStatsMap.get(oldWorkerId);
- checkNotNull(oldWorkerStats);
+ Objects.requireNonNull(oldWorkerStats);
oldWorkerStats.instancesRemoved++;
oldWorkerStats.finalNumAssignments--;
}
WorkerStats newWorkerStats = workerStatsMap.get(newWorkerId);
- checkNotNull(newWorkerStats);
+ Objects.requireNonNull(newWorkerStats);
newWorkerStats.instancesAdded++;
newWorkerStats.finalNumAssignments++;
@@ -873,7 +872,7 @@ public class SchedulerManager implements AutoCloseable {
public void updatedAssignment(Assignment assignment) {
String workerId = assignment.getWorkerId();
WorkerStats stats = workerStatsMap.get(workerId);
- checkNotNull(stats);
+ Objects.requireNonNull(stats);
stats.instancesUpdated++;
}
diff --git a/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/ComponentImpl.java b/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/ComponentImpl.java
index f628ebbb7f9..f3ebef89b92 100644
--- a/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/ComponentImpl.java
+++ b/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/ComponentImpl.java
@@ -18,7 +18,6 @@
*/
package org.apache.pulsar.functions.worker.rest.api;
-import static com.google.common.base.Preconditions.checkNotNull;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.apache.bookkeeper.common.concurrent.FutureUtils.result;
@@ -47,6 +46,7 @@ import java.util.Base64;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
+import java.util.Objects;
import java.util.TreeMap;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
@@ -274,7 +274,7 @@ public abstract class ComponentImpl implements Component<PulsarWorkerService> {
@Override
public PulsarWorkerService worker() {
try {
- return checkNotNull(workerServiceSupplier.get());
+ return Objects.requireNonNull(workerServiceSupplier.get());
} catch (Throwable t) {
log.info("Failed to get worker service", t);
throw t;
diff --git a/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/WorkerImpl.java b/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/WorkerImpl.java
index 7eef8ae7894..0569e5a4d55 100644
--- a/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/WorkerImpl.java
+++ b/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/WorkerImpl.java
@@ -18,7 +18,6 @@
*/
package org.apache.pulsar.functions.worker.rest.api;
-import static com.google.common.base.Preconditions.checkNotNull;
import static org.apache.pulsar.functions.worker.rest.RestUtils.throwUnavailableException;
import java.io.IOException;
import java.net.URI;
@@ -27,6 +26,7 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.function.Supplier;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;
@@ -61,7 +61,7 @@ public class WorkerImpl implements Workers<PulsarWorkerService> {
private PulsarWorkerService worker() {
try {
- return checkNotNull(workerServiceSupplier.get());
+ return Objects.requireNonNull(workerServiceSupplier.get());
} catch (Throwable t) {
log.info("Failed to get worker service", t);
throw t;
diff --git a/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/scheduler/RoundRobinScheduler.java b/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/scheduler/RoundRobinScheduler.java
index 444cceda602..8cf905f7a83 100644
--- a/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/scheduler/RoundRobinScheduler.java
+++ b/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/scheduler/RoundRobinScheduler.java
@@ -18,7 +18,7 @@
*/
package org.apache.pulsar.functions.worker.scheduler;
-import com.google.common.collect.Lists;
+import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedList;
@@ -38,7 +38,7 @@ public class RoundRobinScheduler implements IScheduler {
List<Assignment> currentAssignments, Set<String> workers) {
Map<String, List<Instance>> workerIdToAssignment = new HashMap<>();
- List<Assignment> newAssignments = Lists.newArrayList();
+ List<Assignment> newAssignments = new ArrayList<>();
for (String workerId : workers) {
workerIdToAssignment.put(workerId, new LinkedList<>());
diff --git a/pulsar-functions/worker/src/test/java/org/apache/pulsar/functions/worker/FunctionRuntimeManagerTest.java b/pulsar-functions/worker/src/test/java/org/apache/pulsar/functions/worker/FunctionRuntimeManagerTest.java
index bfaa7431660..ceda6f89eb8 100644
--- a/pulsar-functions/worker/src/test/java/org/apache/pulsar/functions/worker/FunctionRuntimeManagerTest.java
+++ b/pulsar-functions/worker/src/test/java/org/apache/pulsar/functions/worker/FunctionRuntimeManagerTest.java
@@ -38,7 +38,6 @@ import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
-import com.google.common.collect.ImmutableList;
import io.netty.buffer.Unpooled;
import java.util.HashMap;
import java.util.Iterator;
@@ -1225,7 +1224,7 @@ public class FunctionRuntimeManagerTest {
.setInstance(Function.Instance.newBuilder()
.setFunctionMetaData(function).setInstanceId(0).build())
.build();
- doReturn(ImmutableList.of(assignment)).when(functionRuntimeManager)
+ doReturn(List.of(assignment)).when(functionRuntimeManager)
.findFunctionAssignments("test-tenant", "test-namespace", "function");
functionRuntimeManager.restartFunctionInstances("test-tenant", "test-namespace", "function");
if (expectRestartByPulsarAdmin) {
diff --git a/pulsar-functions/worker/src/test/java/org/apache/pulsar/functions/worker/SchedulerManagerTest.java b/pulsar-functions/worker/src/test/java/org/apache/pulsar/functions/worker/SchedulerManagerTest.java
index 62df46f8b33..0d2f1bda952 100644
--- a/pulsar-functions/worker/src/test/java/org/apache/pulsar/functions/worker/SchedulerManagerTest.java
+++ b/pulsar-functions/worker/src/test/java/org/apache/pulsar/functions/worker/SchedulerManagerTest.java
@@ -31,11 +31,11 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
-import com.google.common.collect.Sets;
import com.google.protobuf.InvalidProtocolBufferException;
import io.netty.util.concurrent.DefaultThreadFactory;
import java.lang.reflect.Method;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -468,7 +468,7 @@ public class SchedulerManagerTest {
invocations = getMethodInvocationDetails(message, TypedMessageBuilder.class.getMethod("value",
Object.class));
- Set<Assignment> allAssignments = Sets.newHashSet();
+ Set<Assignment> allAssignments = new HashSet<>();
invocations.forEach(invocation -> {
try {
allAssignments.add(Assignment.parseFrom((byte[]) invocation.getRawArguments()[0]));
@@ -543,7 +543,7 @@ public class SchedulerManagerTest {
Assert.assertEquals(assignment, expectedAssignment);
}
- Set<Assignment> allAssignments = Sets.newHashSet();
+ Set<Assignment> allAssignments = new HashSet<>();
invocations.forEach(invocation -> {
try {
allAssignments.add(Assignment.parseFrom((byte[]) invocation.getRawArguments()[0]));
@@ -610,7 +610,7 @@ public class SchedulerManagerTest {
invocations = getMethodInvocationDetails(message, TypedMessageBuilder.class.getMethod("value",
Object.class));
- Set<Assignment> allAssignments2 = Sets.newHashSet();
+ Set<Assignment> allAssignments2 = new HashSet<>();
invocations.forEach(invocation -> {
try {
allAssignments2.add(Assignment.parseFrom((byte[]) invocation.getRawArguments()[0]));
@@ -755,7 +755,7 @@ public class SchedulerManagerTest {
invocations = getMethodInvocationDetails(message, TypedMessageBuilder.class.getMethod("value",
Object.class));
- Set<Assignment> allAssignments = Sets.newHashSet();
+ Set<Assignment> allAssignments = new HashSet<>();
invocations.forEach(invocation -> {
try {
allAssignments.add(Assignment.parseFrom((byte[]) invocation.getRawArguments()[0]));
@@ -818,7 +818,7 @@ public class SchedulerManagerTest {
invocations = getMethodInvocationDetails(message, TypedMessageBuilder.class.getMethod("value",
Object.class));
- Set<Assignment> allAssignments2 = Sets.newHashSet();
+ Set<Assignment> allAssignments2 = new HashSet<>();
invocations.forEach(invocation -> {
try {
allAssignments2.add(Assignment.parseFrom((byte[]) invocation.getRawArguments()[0]));
diff --git a/pulsar-functions/worker/src/test/java/org/apache/pulsar/functions/worker/dlog/DLInputStreamTest.java b/pulsar-functions/worker/src/test/java/org/apache/pulsar/functions/worker/dlog/DLInputStreamTest.java
index ca16c63a3ef..a1f1688b5e6 100644
--- a/pulsar-functions/worker/src/test/java/org/apache/pulsar/functions/worker/dlog/DLInputStreamTest.java
+++ b/pulsar-functions/worker/src/test/java/org/apache/pulsar/functions/worker/dlog/DLInputStreamTest.java
@@ -18,7 +18,6 @@
*/
package org.apache.pulsar.functions.worker.dlog;
-import static com.google.common.base.Charsets.UTF_8;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyBoolean;
import static org.mockito.Mockito.eq;
@@ -28,6 +27,8 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.testng.AssertJUnit.assertEquals;
import java.io.ByteArrayInputStream;
+import java.nio.charset.StandardCharsets;
+
import org.apache.distributedlog.DLSN;
import org.apache.distributedlog.LogRecordWithDLSN;
import org.apache.distributedlog.api.DistributedLogManager;
@@ -83,7 +84,7 @@ public class DLInputStreamTest {
LogReader reader = mock(LogReader.class);
when(dlm.getInputStream(any(DLSN.class))).thenReturn(reader);
- byte[] data = "test-read".getBytes(UTF_8);
+ byte[] data = "test-read".getBytes(StandardCharsets.UTF_8);
LogRecordWithDLSN record = mock(LogRecordWithDLSN.class);
when(record.getPayLoadInputStream())
.thenReturn(new ByteArrayInputStream(data));
diff --git a/pulsar-functions/worker/src/test/java/org/apache/pulsar/functions/worker/executor/MockExecutorController.java b/pulsar-functions/worker/src/test/java/org/apache/pulsar/functions/worker/executor/MockExecutorController.java
index 629af87547d..ee863177441 100644
--- a/pulsar-functions/worker/src/test/java/org/apache/pulsar/functions/worker/executor/MockExecutorController.java
+++ b/pulsar-functions/worker/src/test/java/org/apache/pulsar/functions/worker/executor/MockExecutorController.java
@@ -22,9 +22,9 @@ import static com.google.common.base.Preconditions.checkArgument;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyLong;
import static org.mockito.Mockito.doAnswer;
-import com.google.common.collect.Lists;
import com.google.common.util.concurrent.SettableFuture;
import java.time.Duration;
+import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.CompletableFuture;
@@ -113,7 +113,7 @@ public class MockExecutorController {
@Getter
private final MockClock clock = new MockClock();
- private final List<DeferredTask> deferredTasks = Lists.newArrayList();
+ private final List<DeferredTask> deferredTasks = new ArrayList<>();
public MockExecutorController controlSubmit(ScheduledExecutorService service) {
doAnswer(answerNow()).when(service).submit(any(Runnable.class));
@@ -197,7 +197,7 @@ public class MockExecutorController {
public void advance(Duration duration) {
clock.advance(duration);
Iterator<DeferredTask> entries = deferredTasks.iterator();
- List<DeferredTask> toExecute = Lists.newArrayList();
+ List<DeferredTask> toExecute = new ArrayList<>();
while (entries.hasNext()) {
DeferredTask next = entries.next();
if (next.getDelay(TimeUnit.MILLISECONDS) <= 0) {
diff --git a/pulsar-metadata/pom.xml b/pulsar-metadata/pom.xml
index 935fc878a62..cb4c193cb30 100644
--- a/pulsar-metadata/pom.xml
+++ b/pulsar-metadata/pom.xml
@@ -103,6 +103,24 @@
<build>
<plugins>
+ <plugin>
+ <groupId>org.gaul</groupId>
+ <artifactId>modernizer-maven-plugin</artifactId>
+ <configuration>
+ <failOnViolations>true</failOnViolations>
+ <javaVersion>17</javaVersion>
+ </configuration>
+ <executions>
+ <execution>
+ <id>modernizer</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>modernizer</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
diff --git a/pulsar-package-management/core/pom.xml b/pulsar-package-management/core/pom.xml
index 13e01377fcf..fb5b5671bc6 100644
--- a/pulsar-package-management/core/pom.xml
+++ b/pulsar-package-management/core/pom.xml
@@ -52,6 +52,24 @@
<build>
<plugins>
+ <plugin>
+ <groupId>org.gaul</groupId>
+ <artifactId>modernizer-maven-plugin</artifactId>
+ <configuration>
+ <failOnViolations>true</failOnViolations>
+ <javaVersion>17</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>