Skip to content

Commit f7318a5

Browse files
committed
fix(checkstyle): resolve all remaining violations across connector/storage/sdk modules
- Fix 115 real violations in 30+ files (EmptyLineSeparator, NeedBraces, AvoidStarImport, EmptyCatchBlock, VariableDeclarationUsageDistance, LocalVariableName, OverloadMethodsDeclarationOrder, Indentation, non-ASCII) - Expand wildcard imports to explicit types (pulsar/rabbitmq/redis/s3/jdbc) - CloudEventsClient: rename empty-catch var to 'expected'; reorder unsubscribe overloads - Kafka IT: replace System.out.println with @slf4j logger; final vars - Fix jdbc build.gradle: exclude flat ANTLR generated sources from checkstyle by absolute path (package-path excludes cannot match srcDir-relative flat files), eliminating 30k+ generated-code warnings Verified: full checkstyleMain + checkstyleTest BUILD SUCCESSFUL on JDK 21.
1 parent 4cc9f2f commit f7318a5

66 files changed

Lines changed: 179 additions & 95 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

eventmesh-connector-plugin/eventmesh-connector-http/src/main/java/org/apache/eventmesh/connector/http/sink/HttpSinkConnector.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@
3030
public class HttpSinkConnector implements SinkConnector {
3131

3232
private String url;
33+
3334
@Override
3435
public void init(Properties props) {
3536
url = props.getProperty("connector.url", "http://localhost:9090/sink");
3637
}
38+
3739
@Override
3840
public void put(List<CloudEvent> events) {
3941
for (CloudEvent event : events) {
@@ -50,6 +52,7 @@ public void put(List<CloudEvent> events) {
5052
}
5153
}
5254
}
55+
5356
@Override
5457
public void commit(List<CloudEvent> written) {
5558

eventmesh-connector-plugin/eventmesh-connector-http/src/main/java/org/apache/eventmesh/connector/http/source/HttpSourceConnector.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public class HttpSourceConnector implements SourceConnector {
3535

3636
private java.util.concurrent.LinkedBlockingQueue<byte[]> buffer;
3737
private com.sun.net.httpserver.HttpServer server;
38+
3839
@Override
3940
public void init(Properties props) {
4041
int port = Integer.parseInt(props.getProperty("connector.port", "8082"));
@@ -54,17 +55,21 @@ public void init(Properties props) {
5455
throw new RuntimeException(e);
5556
}
5657
}
58+
5759
@Override
5860
public List<CloudEvent> poll() {
59-
if (buffer == null)
61+
if (buffer == null) {
6062
return Collections.emptyList();
63+
}
6164
List<CloudEvent> out = new ArrayList<>();
6265
byte[] body;
63-
while ((body = buffer.poll()) != null)
66+
while ((body = buffer.poll()) != null) {
6467
out.add(CloudEventBuilder.v1().withId("http-" + System.nanoTime()).withSource(URI.create("http-webhook"))
6568
.withType("http.request").withDataContentType("application/octet-stream").withData(body).build());
69+
}
6670
return out;
6771
}
72+
6873
@Override
6974
public void commit(CloudEvent lastPublished) {
7075

eventmesh-connector-plugin/eventmesh-connector-jdbc/build.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,11 @@ generateGrammarSource {
2222
tasks.named('packageSources') {
2323
dependsOn tasks.named('generateGrammarSource')
2424
}
25+
26+
// ANTLR emits generated sources flat under build/generated-src/antlr/main (no package
27+
// sub-dirs), so the root project's package-path based checkstyle excludes cannot match
28+
// them. Strip that tree from checkstyle input here to avoid tens of thousands of
29+
// generated-code warnings failing the build.
30+
tasks.withType(Checkstyle).configureEach {
31+
exclude { it.file.absolutePath.replace(File.separatorChar, (char) '/').contains('/build/generated-src/antlr/') }
32+
}

eventmesh-connector-plugin/eventmesh-connector-jdbc/src/main/java/org/apache/eventmesh/connector/jdbc/sink/JdbcSinkConnector.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919

2020
import org.apache.eventmesh.connector.SinkConnector;
2121

22-
import java.sql.*;
22+
import java.sql.Connection;
23+
import java.sql.DriverManager;
24+
import java.sql.PreparedStatement;
2325
import java.util.List;
2426
import java.util.Properties;
2527

@@ -33,6 +35,7 @@ public class JdbcSinkConnector implements SinkConnector {
3335
private Connection conn;
3436
private String insertSql;
3537
private Properties props;
38+
3639
@Override
3740
public void init(Properties props) {
3841
this.props = props;
@@ -44,6 +47,7 @@ public void init(Properties props) {
4447
throw new RuntimeException(e);
4548
}
4649
}
50+
4751
@Override
4852
public void put(List<CloudEvent> events) {
4953
try (PreparedStatement ps = conn.prepareStatement(insertSql)) {
@@ -57,6 +61,7 @@ public void put(List<CloudEvent> events) {
5761
throw new RuntimeException(e);
5862
}
5963
}
64+
6065
@Override
6166
public void commit(List<CloudEvent> written) {
6267

eventmesh-connector-plugin/eventmesh-connector-jdbc/src/main/java/org/apache/eventmesh/connector/jdbc/source/JdbcSourceConnector.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@
2121

2222
import java.net.URI;
2323
import java.nio.charset.StandardCharsets;
24-
import java.sql.*;
24+
import java.sql.Connection;
25+
import java.sql.DriverManager;
26+
import java.sql.PreparedStatement;
27+
import java.sql.ResultSet;
2528
import java.util.ArrayList;
2629
import java.util.List;
2730
import java.util.Properties;
@@ -37,6 +40,7 @@ public class JdbcSourceConnector implements SourceConnector {
3740
private Connection conn;
3841
private String query;
3942
private String lastId;
43+
4044
@Override
4145
public void init(Properties props) {
4246
String url = props.getProperty("connector.jdbcUrl", "jdbc:mysql://localhost:3306/test");
@@ -48,6 +52,7 @@ public void init(Properties props) {
4852
throw new RuntimeException(e);
4953
}
5054
}
55+
5156
@Override
5257
public List<CloudEvent> poll() {
5358
List<CloudEvent> out = new ArrayList<>();
@@ -66,6 +71,7 @@ public List<CloudEvent> poll() {
6671
}
6772
return out;
6873
}
74+
6975
@Override
7076
public void commit(CloudEvent lastPublished) {
7177

eventmesh-connector-plugin/eventmesh-connector-knative/src/main/java/org/apache/eventmesh/connector/knative/sink/KnativeSinkConnector.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,13 @@ public class KnativeSinkConnector implements SinkConnector {
3131

3232
private String sinkUrl;
3333
private Properties props;
34+
3435
@Override
3536
public void init(Properties props) {
3637
this.props = props;
3738
sinkUrl = props.getProperty("connector.sinkUrl", "http://localhost:8080/sink");
3839
}
40+
3941
@Override
4042
public void put(List<CloudEvent> events) {
4143
for (CloudEvent event : events) {
@@ -52,6 +54,7 @@ public void put(List<CloudEvent> events) {
5254
}
5355
}
5456
}
57+
5558
@Override
5659
public void commit(List<CloudEvent> written) {
5760

eventmesh-connector-plugin/eventmesh-connector-knative/src/main/java/org/apache/eventmesh/connector/knative/source/KnativeSourceConnector.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public class KnativeSourceConnector implements SourceConnector {
3535

3636
private java.util.concurrent.LinkedBlockingQueue<byte[]> buffer;
3737
private com.sun.net.httpserver.HttpServer server;
38+
3839
@Override
3940
public void init(Properties props) {
4041
int port = Integer.parseInt(props.getProperty("connector.port", "8080"));
@@ -54,17 +55,21 @@ public void init(Properties props) {
5455
throw new RuntimeException(e);
5556
}
5657
}
58+
5759
@Override
5860
public List<CloudEvent> poll() {
59-
if (buffer == null)
61+
if (buffer == null) {
6062
return Collections.emptyList();
63+
}
6164
List<CloudEvent> out = new ArrayList<>();
6265
byte[] body;
63-
while ((body = buffer.poll()) != null)
66+
while ((body = buffer.poll()) != null) {
6467
out.add(CloudEventBuilder.v1().withId("knative-" + System.nanoTime()).withSource(URI.create("knative"))
6568
.withType("knative.event").withDataContentType("application/octet-stream").withData(body).build());
69+
}
6670
return out;
6771
}
72+
6873
@Override
6974
public void commit(CloudEvent lastPublished) {
7075

eventmesh-connector-plugin/eventmesh-connector-lark/src/main/java/org/apache/eventmesh/connector/lark/sink/LarkSinkConnector.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@
3030
public class LarkSinkConnector implements SinkConnector {
3131

3232
private String webhookUrl;
33+
3334
@Override
3435
public void init(Properties props) {
3536
webhookUrl = props.getProperty("connector.webhookUrl", "");
3637
}
38+
3739
@Override
3840
public void put(List<CloudEvent> events) {
3941
for (CloudEvent event : events) {
@@ -50,6 +52,7 @@ public void put(List<CloudEvent> events) {
5052
}
5153
}
5254
}
55+
5356
@Override
5457
public void commit(List<CloudEvent> written) {
5558

eventmesh-connector-plugin/eventmesh-connector-mongodb/src/main/java/org/apache/eventmesh/connector/mongodb/sink/MongodbSinkConnector.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public class MongodbSinkConnector implements SinkConnector {
3636

3737
private com.mongodb.client.MongoCollection<Document> collection;
3838
private Properties props;
39+
3940
@Override
4041
public void init(Properties props) {
4142
this.props = props;
@@ -44,13 +45,15 @@ public void init(Properties props) {
4445
String coll = props.getProperty("connector.collection", "sink");
4546
collection = MongoClients.create(uri).getDatabase(db).getCollection(coll);
4647
}
48+
4749
@Override
4850
public void put(List<CloudEvent> events) {
4951
for (CloudEvent event : events) {
5052
byte[] data = event.getData() != null ? event.getData().toBytes() : new byte[0];
5153
collection.insertOne(Document.parse(new String(data, StandardCharsets.UTF_8)));
5254
}
5355
}
56+
5457
@Override
5558
public void commit(List<CloudEvent> written) {
5659

eventmesh-connector-plugin/eventmesh-connector-mongodb/src/main/java/org/apache/eventmesh/connector/mongodb/source/MongodbSourceConnector.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public class MongodbSourceConnector implements SourceConnector {
4141
private MongoClient client;
4242
private com.mongodb.client.MongoCollection<Document> collection;
4343
private com.mongodb.client.ChangeStreamIterable<Document> changeStream;
44+
4445
@Override
4546
public void init(Properties props) {
4647
String uri = props.getProperty("connector.mongoUri", "mongodb://localhost:27017");
@@ -50,18 +51,21 @@ public void init(Properties props) {
5051
collection = client.getDatabase(db).getCollection(coll);
5152
changeStream = collection.watch();
5253
}
54+
5355
@Override
5456
public List<CloudEvent> poll() {
5557
List<CloudEvent> out = new ArrayList<>();
5658
try {
5759
com.mongodb.client.MongoChangeStreamCursor<com.mongodb.client.model.changestream.ChangeStreamDocument<Document>> cursor =
5860
changeStream.cursor();
5961
for (int i = 0; i < 100; i++) {
60-
if (!cursor.hasNext())
62+
if (!cursor.hasNext()) {
6163
break;
64+
}
6265
com.mongodb.client.model.changestream.ChangeStreamDocument<Document> csd = cursor.next();
63-
if (csd == null || csd.getFullDocument() == null)
66+
if (csd == null || csd.getFullDocument() == null) {
6467
break;
68+
}
6569
Document doc = csd.getFullDocument();
6670
out.add(CloudEventBuilder.v1().withId("mongo-" + doc.get("_id"))
6771
.withSource(URI.create("mongodb")).withType("mongodb.change")
@@ -73,6 +77,7 @@ public List<CloudEvent> poll() {
7377
}
7478
return out;
7579
}
80+
7681
@Override
7782
public void commit(CloudEvent lastPublished) {
7883

0 commit comments

Comments
 (0)