From 8319e8ab7d0618ecb6b84ba04e8ade705b267d1b Mon Sep 17 00:00:00 2001
From: goflutterjava <95280282+goflutterjava@users.noreply.github.com>
Date: Tue, 4 Jan 2022 14:05:18 +0800
Subject: [PATCH] Enable CheckStyle Plugin in Pulsar Test Mocks (#13581)
---
testmocks/pom.xml | 18 +++++++++
.../client/PulsarMockBookKeeper.java | 22 +++++-----
.../client/PulsarMockLedgerHandle.java | 40 +++++++++----------
.../client/PulsarMockReadHandle.java | 3 +-
.../bookkeeper/client/package-info.java | 19 +++++++++
.../zookeeper/MockZooKeeperSession.java | 6 +--
.../org/apache/zookeeper/package-info.java | 19 +++++++++
7 files changed, 91 insertions(+), 36 deletions(-)
create mode 100644 testmocks/src/main/java/org/apache/bookkeeper/client/package-info.java
create mode 100644 testmocks/src/main/java/org/apache/zookeeper/package-info.java
diff --git a/testmocks/pom.xml b/testmocks/pom.xml
index 2dea92fa863a5..c7e2100702283 100644
--- a/testmocks/pom.xml
+++ b/testmocks/pom.xml
@@ -65,4 +65,22 @@
+
+
+
+ org.apache.maven.plugins
+ maven-checkstyle-plugin
+
+
+ checkstyle
+ verify
+
+ check
+
+
+
+
+
+
+
diff --git a/testmocks/src/main/java/org/apache/bookkeeper/client/PulsarMockBookKeeper.java b/testmocks/src/main/java/org/apache/bookkeeper/client/PulsarMockBookKeeper.java
index f83e1c73a06cf..50df4b6b0df0f 100644
--- a/testmocks/src/main/java/org/apache/bookkeeper/client/PulsarMockBookKeeper.java
+++ b/testmocks/src/main/java/org/apache/bookkeeper/client/PulsarMockBookKeeper.java
@@ -75,8 +75,8 @@ public ClientConfiguration getConf() {
return super.getConf();
}
- Map ledgers = new ConcurrentHashMap<>();
- AtomicLong sequence = new AtomicLong(3);
+ final Map ledgers = new ConcurrentHashMap<>();
+ final AtomicLong sequence = new AtomicLong(3);
CompletableFuture defaultResponse = CompletableFuture.completedFuture(null);
private static final List ensemble = Collections.unmodifiableList(Lists.newArrayList(
@@ -88,8 +88,8 @@ public static Collection getMockEnsemble() {
return ensemble;
}
- Queue addEntryDelaysMillis = new ConcurrentLinkedQueue<>();
- List> failures = new ArrayList<>();
+ final Queue addEntryDelaysMillis = new ConcurrentLinkedQueue<>();
+ final List> failures = new ArrayList<>();
public PulsarMockBookKeeper(OrderedExecutor orderedExecutor) throws Exception {
this.orderedExecutor = orderedExecutor;
@@ -120,7 +120,8 @@ public void asyncCreateLedger(int ensSize, int writeQuorumSize, int ackQuorumSiz
try {
long id = sequence.getAndIncrement();
log.info("Creating ledger {}", id);
- PulsarMockLedgerHandle lh = new PulsarMockLedgerHandle(PulsarMockBookKeeper.this, id, digestType, passwd);
+ PulsarMockLedgerHandle lh =
+ new PulsarMockLedgerHandle(PulsarMockBookKeeper.this, id, digestType, passwd);
ledgers.put(id, lh);
return FutureUtils.value(lh);
} catch (Throwable t) {
@@ -303,7 +304,7 @@ void checkProgrammedFail() throws BKException, InterruptedException {
getProgrammedFailure().get();
} catch (ExecutionException ee) {
if (ee.getCause() instanceof BKException) {
- throw (BKException)ee.getCause();
+ throw (BKException) ee.getCause();
} else {
throw new BKException.BKUnexpectedConditionException();
}
@@ -331,7 +332,7 @@ public void failAfter(int steps, int rc) {
private int emptyLedgerAfter = -1;
/**
- * After N times, make a ledger to appear to be empty
+ * After N times, make a ledger to appear to be empty.
*/
public synchronized void returnEmptyLedgerAfter(int steps) {
emptyLedgerAfter = steps;
@@ -373,12 +374,12 @@ public CompletableFuture>> getWritableBookies() {
@Override
public CompletableFuture>> getAllBookies() {
- return CompletableFuture.completedFuture(new Versioned>(new HashSet<>(ensemble), new LongVersion(0)));
+ return CompletableFuture.completedFuture(new Versioned<>(new HashSet<>(ensemble), new LongVersion(0)));
}
@Override
public CompletableFuture>> getReadOnlyBookies() {
- return CompletableFuture.completedFuture(new Versioned>(new HashSet<>(), new LongVersion(0)));
+ return CompletableFuture.completedFuture(new Versioned<>(new HashSet<>(), new LongVersion(0)));
}
@Override
@@ -404,7 +405,8 @@ public void unwatchReadOnlyBookies(RegistrationListener listener) {
private final MetadataClientDriver metadataClientDriver = new MetadataClientDriver() {
@Override
- public MetadataClientDriver initialize(ClientConfiguration conf, ScheduledExecutorService scheduler, StatsLogger statsLogger, Optional