Skip to content

Commit 7e08c1c

Browse files
committed
Java 17 support
Signed-off-by: Andras Katona <[email protected]>
1 parent f472590 commit 7e08c1c

File tree

7 files changed

+35
-13
lines changed

7 files changed

+35
-13
lines changed

.github/workflows/ci.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
strategy:
1818
fail-fast: false
1919
matrix:
20-
java-ver: [11]
20+
java-ver: [11, 17]
2121
java-dist: ['microsoft', 'temurin']
2222
steps:
2323
- uses: actions/checkout@v4
@@ -39,7 +39,7 @@ jobs:
3939
strategy:
4040
fail-fast: false
4141
matrix:
42-
java-ver: [11]
42+
java-ver: [11, 17]
4343
java-dist: ['microsoft', 'temurin']
4444
steps:
4545
- uses: actions/checkout@v4

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Cruise Control for Apache Kafka
6060
* The `kafka_2_0_to_2_3` and `kafka_0_11_and_1_0` branches compile with `Scala 2.11`.
6161
* The branch `migrate_to_kafka_2_4` compiles with `Scala 2.12`.
6262
* The branch `migrate_to_kafka_2_5` compile with `Scala 2.13`.
63-
* This project requires Java 11.
63+
* This project requires Java 11, also compatible with Java 17.
6464

6565
#### Known Compatibility Issues ####
6666
* Support for Apache Kafka `2.0`, `2.1`, `2.2`, and `2.3` requires [KAFKA-8875](https://issues.apache.org/jira/browse/KAFKA-8875) hotfix.
@@ -77,7 +77,7 @@ Cruise Control for Apache Kafka
7777
&& git tag -a 0.1.10 -m "Init local version."`
7878
1. This step is required if `CruiseControlMetricsReporter` is used for metrics collection (i.e. the default for Cruise
7979
Control). The metrics reporter periodically samples the Kafka raw metrics on the broker and sends them to a Kafka topic.
80-
* `./gradlew jar` (Note: This project requires Java 11)
80+
* `./gradlew jar` (Note: This project requires Java 11 or 17)
8181
* Copy `./cruise-control-metrics-reporter/build/libs/cruise-control-metrics-reporter-A.B.C.jar` (Where `A.B.C` is
8282
the version of the Cruise Control) to your Kafka server dependency jar folder. For Apache Kafka, the folder would
8383
be `core/build/dependant-libs-SCALA_VERSION/` (for a Kafka source checkout) or `libs/` (for a Kafka release download).

build.gradle

+18-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ plugins {
88
id "idea"
99
id "jacoco" // Java Code Coverage plugin
1010
id "com.github.ben-manes.versions" version "0.42.0"
11-
id "com.github.spotbugs" version "6.0.6" apply false
11+
id "com.github.spotbugs" version "6.0.25" apply false
1212
id "checkstyle"
1313
id "org.openapi.generator" version "5.3.0"
1414
}
@@ -45,6 +45,18 @@ project.ext {
4545
buildVersionFileName = "cruise-control-version.properties"
4646
commitId = project.hasProperty('commitId') ? commitId : null
4747
scalaBinaryVersion = getScalaBinaryVersion(scalaVersion)
48+
49+
defaultTestJvmArgs = []
50+
// "JEP 403: Strongly Encapsulate JDK Internals" causes some tests to fail when they try
51+
// to access internals (often via mocking libraries). We use `--add-opens` as a workaround
52+
if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_16))
53+
defaultTestJvmArgs.addAll(
54+
"--add-opens=java.base/java.lang.reflect=ALL-UNNAMED",
55+
"--add-opens=java.base/java.lang=ALL-UNNAMED",
56+
"--add-opens=java.base/java.time=ALL-UNNAMED",
57+
"--add-opens=java.base/java.util.concurrent=ALL-UNNAMED",
58+
"--add-opens=java.base/java.util=ALL-UNNAMED"
59+
)
4860
}
4961

5062
allprojects {
@@ -104,7 +116,7 @@ subprojects {
104116
}
105117

106118
spotbugs {
107-
toolVersion = '4.7.1'
119+
toolVersion = '4.8.6'
108120
excludeFilter = file("$rootDir/gradle/findbugs-exclude.xml")
109121
ignoreFailures = false
110122
jvmArgs = [ '-Xms512m' ]
@@ -137,6 +149,8 @@ subprojects {
137149
}
138150

139151
test {
152+
jvmArgs += defaultTestJvmArgs
153+
140154
useJUnit {}
141155
testLogging {
142156
events "passed", "failed", "skipped"
@@ -175,7 +189,7 @@ project(':cruise-control-core') {
175189
implementation "org.apache.logging.log4j:log4j-slf4j-impl:2.17.2"
176190
implementation 'org.apache.commons:commons-math3:3.6.1'
177191
api "org.eclipse.jetty:jetty-servlet:${jettyVersion}"
178-
implementation 'com.google.code.findbugs:jsr305:3.0.2'
192+
implementation 'com.github.spotbugs:spotbugs-annotations:4.8.6'
179193

180194
api "io.vertx:vertx-core:${vertxVersion}"
181195
api "io.vertx:vertx-web:${vertxVersion}"
@@ -311,7 +325,7 @@ project(':cruise-control') {
311325
testImplementation project(path: ':cruise-control-core', configuration: 'testOutput')
312326
testImplementation "org.scala-lang:scala-library:$scalaVersion"
313327
testImplementation 'junit:junit:4.13.2'
314-
testImplementation 'org.easymock:easymock:4.3'
328+
testImplementation 'org.easymock:easymock:5.5.0'
315329
testImplementation "org.apache.kafka:kafka_$scalaBinaryVersion:$kafkaVersion:test"
316330
testImplementation "org.apache.kafka:kafka-clients:$kafkaVersion:test"
317331
testImplementation 'commons-io:commons-io:2.11.0'

cruise-control/src/main/java/com/linkedin/kafka/cruisecontrol/config/BrokerCapacityConfigFileResolver.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,10 @@ private void loadCapacities() throws FileNotFoundException {
298298
Set<BrokerCapacity> brokerCapacities = ((BrokerCapacities) gson.fromJson(reader, BrokerCapacities.class)).brokerCapacities;
299299
capacitiesForBrokers = new HashMap<>();
300300
Set<Boolean> numCoresConfigConsistency = new HashSet<>();
301-
for (BrokerCapacity bc : brokerCapacities) {
302-
capacitiesForBrokers.put(bc.brokerId, getBrokerCapacityInfo(bc, numCoresConfigConsistency));
301+
if (brokerCapacities != null) {
302+
for (BrokerCapacity bc : brokerCapacities) {
303+
capacitiesForBrokers.put(bc.brokerId, getBrokerCapacityInfo(bc, numCoresConfigConsistency));
304+
}
303305
}
304306
} finally {
305307
try {

cruise-control/src/main/java/com/linkedin/kafka/cruisecontrol/config/BrokerSetFileResolver.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,10 @@ private Map<String, Set<Integer>> loadBrokerSetData() throws IOException {
8484
final BrokerSets brokerSets = gson.fromJson(reader, BrokerSets.class);
8585
final Set<BrokerSet> brokerSetSet = brokerSets.brokerSets;
8686
final Map<String, Set<Integer>> brokerIdsByBrokerSetId = new HashMap<>();
87-
for (BrokerSet brokerSet : brokerSetSet) {
88-
brokerIdsByBrokerSetId.put(brokerSet.brokerSetId, brokerSet.brokerIds);
87+
if (brokerSetSet != null) {
88+
for (BrokerSet brokerSet : brokerSetSet) {
89+
brokerIdsByBrokerSetId.put(brokerSet.brokerSetId, brokerSet.brokerIds);
90+
}
8991
}
9092
return brokerIdsByBrokerSetId;
9193
}

cruise-control/src/test/java/com/linkedin/kafka/cruisecontrol/analyzer/RemoveDisksTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public static Collection<Object[]> buildParameters() {
9898
new IntraBrokerDiskCapacityGoal(true),
9999
cluster,
100100
kafkaCruiseControlConfig,
101-
replicaLoad != TestConstants.LARGE_BROKER_CAPACITY / 2 * balancingConstraint.capacityThreshold(Resource.DISK)
101+
Math.abs(replicaLoad - TestConstants.LARGE_BROKER_CAPACITY / 2 * balancingConstraint.capacityThreshold(Resource.DISK)) > .0000001
102102
});
103103
}
104104

gradle/findbugs-exclude.xml

+4
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@
7979
<Bug pattern="SF_SWITCH_FALLTHROUGH" />
8080
</Match>
8181

82+
<Match>
83+
<Bug pattern="CT_CONSTRUCTOR_THROW"/>
84+
</Match>
85+
8286
<!-- False positive of DMI_RANDOM_USED_ONLY_ONCE (see https://github.com/spotbugs/spotbugs/issues/1539) -->
8387
<Match>
8488
<Bug pattern="DMI_RANDOM_USED_ONLY_ONCE, ..." />

0 commit comments

Comments
 (0)