Skip to content
Closed
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
5 changes: 3 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,9 @@ jobs:
# --info: For now, we'll generate lots of logs while setting up the GH Actions
# --scan: Publish the build scan. This will only work on PRs from apache/kafka and trunk
# --no-scan: For public fork PRs, we won't attempt to publish the scan
run: |
./gradlew --build-cache --info $SCAN_ARG check releaseTarGz -x test
run: ./gradlew --build-cache --info $SCAN_ARG check releaseTarGz -x test
- name: Sanity Check
run: ./gradlew --build-cache rewriteDryRun
- name: Archive check reports
if: always()
uses: actions/upload-artifact@v4
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,16 @@ The import order is a part of static check. please call `spotlessApply` to optim

./gradlew spotlessApply

#### Rewrite
The build system incorporates [Moderne](https://moderne.io/) rewrite capabilities for automated code transformations.

- **Convention** (e.g., JUnit's naming rules)
- **Refactor** safely (e.g., rename methods, migrate APIs)
- **Modernize** (e.g., Java 8 → Java 17 features)
- **Patterns** (e.g., replace `Vector` with `ArrayList`)

`./gradlew rewriteDryRun`

#### Spotbugs ####
Spotbugs uses static analysis to look for bugs in the code.
You can run spotbugs using:
Expand Down
16 changes: 9 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,22 @@ buildscript {
}

plugins {
id 'com.github.ben-manes.versions' version '0.53.0'
id 'idea'
id 'jacoco'
id 'java-library'
id 'com.diffplug.spotless' version '8.1.0'
id 'com.github.ben-manes.versions' version '0.53.0'
id 'com.github.spotbugs' version '6.4.4' apply false
id 'com.gradleup.shadow' version '8.3.9' apply false
id 'io.swagger.core.v3.swagger-gradle-plugin' version "${swaggerVersion}"
id 'org.nosphere.apache.rat' version '0.8.1'
id 'org.openrewrite.rewrite' version '7.22.0' apply false
Copy link
Author

Choose a reason for hiding this comment

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

just wanted to align and give natural order.

Copy link
Member

Choose a reason for hiding this comment

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

If I read this correctly, org.openrewrite.rewrite is newly added? Others are just reordered.

I am not familiar with this package. Curious to hear from others about it.

Copy link
Author

@Pankraz76 Pankraz76 Dec 17, 2025

Choose a reason for hiding this comment

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

correct.
This versatile SCA tool is already running in checkstyle and spotless.

Highly welcome any feedback, thx.

id 'org.owasp.dependencycheck' version '12.1.8'
id 'org.nosphere.apache.rat' version "0.8.1"
id "io.swagger.core.v3.swagger-gradle-plugin" version "${swaggerVersion}"
Copy link
Author

Choose a reason for hiding this comment

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

if desired will undo.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the cleanup. Like it.


id "com.github.spotbugs" version '6.4.4' apply false
id 'org.scoverage' version '8.1' apply false
id 'com.gradleup.shadow' version '8.3.9' apply false
id 'com.diffplug.spotless' version "8.0.0"
}

apply from: "$rootDir/gradle/rewrite.gradle"

ext {
minClientJavaVersion = 11
minNonClientJavaVersion = 17
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,6 @@ public static ShareAcknowledgeResponse parse(Readable readable, short version) {
);
}

private static boolean matchingTopic(ShareAcknowledgeResponseData.ShareAcknowledgeTopicResponse previousTopic, TopicIdPartition currentTopic) {
Copy link
Author

Choose a reason for hiding this comment

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

this now being the only one unused.

Asking to include here to make, or dedicate/extract?

Sanity Check made to be generic and still individual.

if (previousTopic == null)
return false;
return previousTopic.topicId().equals(currentTopic.topicId());
}

public static ShareAcknowledgeResponseData.PartitionData partitionResponse(TopicIdPartition topicIdPartition, Errors error) {
return partitionResponse(topicIdPartition.topicPartition().partition(), error);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ public class DeleteRecordsHandlerTest {
private final TopicPartition t0p3 = new TopicPartition("t0", 3);
private final Node node1 = new Node(1, "host", 1234);
private final Node node2 = new Node(2, "host", 1235);
private final Map<TopicPartition, RecordsToDelete> recordsToDelete = new HashMap<>() {
{
put(t0p0, RecordsToDelete.beforeOffset(10L));
put(t0p1, RecordsToDelete.beforeOffset(10L));
put(t0p2, RecordsToDelete.beforeOffset(10L));
put(t0p3, RecordsToDelete.beforeOffset(10L));
}
};
private final Map<TopicPartition, RecordsToDelete> recordsToDelete;
{
recordsToDelete = new HashMap<>();
recordsToDelete.put(t0p0, RecordsToDelete.beforeOffset(10L));
recordsToDelete.put(t0p1, RecordsToDelete.beforeOffset(10L));
recordsToDelete.put(t0p2, RecordsToDelete.beforeOffset(10L));
recordsToDelete.put(t0p3, RecordsToDelete.beforeOffset(10L));
}

@Test
public void testBuildRequestSimple() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,16 @@ public final class ListOffsetsHandlerTest {

private final Node node = new Node(1, "host", 1234);

private final Map<TopicPartition, Long> offsetTimestampsByPartition = new HashMap<>() {
{
put(t0p0, ListOffsetsRequest.LATEST_TIMESTAMP);
put(t0p1, ListOffsetsRequest.EARLIEST_TIMESTAMP);
put(t1p0, 123L);
put(t1p1, ListOffsetsRequest.MAX_TIMESTAMP);
put(t2p0, ListOffsetsRequest.EARLIEST_LOCAL_TIMESTAMP);
put(t2p1, ListOffsetsRequest.LATEST_TIERED_TIMESTAMP);
}
};
private final Map<TopicPartition, Long> offsetTimestampsByPartition;
{
offsetTimestampsByPartition = new HashMap<>();
offsetTimestampsByPartition.put(t0p0, ListOffsetsRequest.LATEST_TIMESTAMP);
offsetTimestampsByPartition.put(t0p1, ListOffsetsRequest.EARLIEST_TIMESTAMP);
offsetTimestampsByPartition.put(t1p0, 123L);
offsetTimestampsByPartition.put(t1p1, ListOffsetsRequest.MAX_TIMESTAMP);
offsetTimestampsByPartition.put(t2p0, ListOffsetsRequest.EARLIEST_LOCAL_TIMESTAMP);
offsetTimestampsByPartition.put(t2p1, ListOffsetsRequest.LATEST_TIERED_TIMESTAMP);
}

@Test
public void testBuildRequestSimple() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,11 @@ public class FetchRequestManagerTest {
private final String topicName = "test";
private final String groupId = "test-group";
private final Uuid topicId = Uuid.randomUuid();
private final Map<String, Uuid> topicIds = new HashMap<>() {
{
put(topicName, topicId);
}
};
private final Map<String, Uuid> topicIds;
{
topicIds = new HashMap<>();
topicIds.put(topicName, topicId);
}
private final Map<Uuid, String> topicNames = singletonMap(topicId, topicName);
private final String metricGroup = "consumer" + groupId + "-fetch-manager-metrics";
private final TopicPartition tp0 = new TopicPartition(topicName, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,11 @@ public class FetcherTest {
private final String topicName = "test";
private final String groupId = "test-group";
private final Uuid topicId = Uuid.randomUuid();
private final Map<String, Uuid> topicIds = new HashMap<>() {
{
put(topicName, topicId);
}
};
private final Map<String, Uuid> topicIds;
{
topicIds = new HashMap<>();
topicIds.put(topicName, topicId);
}
private final Map<Uuid, String> topicNames = singletonMap(topicId, topicName);
private final String metricGroup = "consumer" + groupId + "-fetch-manager-metrics";
private final TopicPartition tp0 = new TopicPartition(topicName, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ public class OffsetFetcherTest {

private final String topicName = "test";
private final Uuid topicId = Uuid.randomUuid();
private final Map<String, Uuid> topicIds = new HashMap<>() {
{
put(topicName, topicId);
}
};
private final Map<String, Uuid> topicIds;
{
topicIds = new HashMap<>();
topicIds.put(topicName, topicId);
}
private final TopicPartition tp0 = new TopicPartition(topicName, 0);
private final TopicPartition tp1 = new TopicPartition(topicName, 1);
private final TopicPartition tp2 = new TopicPartition(topicName, 2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,12 @@ public class ShareConsumeRequestManagerTest {
put(topicName2, topicId2);
}
};
private final Map<String, Integer> topicPartitionCounts = new HashMap<>() {
{
put(topicName, 2);
put(topicName2, 1);
}
};
private final Map<String, Integer> topicPartitionCounts;
{
topicPartitionCounts = new HashMap<>();
topicPartitionCounts.put(topicName, 2);
topicPartitionCounts.put(topicName2, 1);
}
private final TopicPartition tp0 = new TopicPartition(topicName, 0);
private final TopicIdPartition tip0 = new TopicIdPartition(topicId, tp0);
private final TopicPartition tp1 = new TopicPartition(topicName, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ public class TopicMetadataFetcherTest {

private final String topicName = "test";
private final Uuid topicId = Uuid.randomUuid();
private final Map<String, Uuid> topicIds = new HashMap<>() {
{
put(topicName, topicId);
}
};
private final Map<String, Uuid> topicIds;
{
topicIds = new HashMap<>();
topicIds.put(topicName, topicId);
}
private final TopicPartition tp0 = new TopicPartition(topicName, 0);
private final int validLeaderEpoch = 0;
private final MetadataResponse initialUpdateResponse =
Expand Down
Loading