Skip to content

Commit 76a9df4

Browse files
authored
KAFKA-17639 Add Java 23 to CI build matrix (apache#17409)
Reviewers: Chia-Ping Tsai <[email protected]>
1 parent 6d804ce commit 76a9df4

File tree

5 files changed

+34
-11
lines changed

5 files changed

+34
-11
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ jobs:
104104
strategy:
105105
fail-fast: false
106106
matrix:
107-
java: [ 21, 11 ] # If we change these, make sure to adjust ci-complete.yml
107+
java: [ 23, 11 ] # If we change these, make sure to adjust ci-complete.yml
108108
name: JUnit tests Java ${{ matrix.java }}
109109
steps:
110110
- name: Checkout code

.github/workflows/ci-complete.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
strategy:
4444
fail-fast: false
4545
matrix:
46-
java: [ 21, 11 ]
46+
java: [ 23, 11 ]
4747
steps:
4848
- name: Env
4949
run: printenv

clients/src/main/java/org/apache/kafka/common/internals/KafkaFutureImpl.java

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,10 @@ private void maybeThrowCancellationException(Throwable cause) {
163163
public T get() throws InterruptedException, ExecutionException {
164164
try {
165165
return completableFuture.get();
166-
} catch (ExecutionException e) {
166+
// In Java 23, When a CompletableFuture is cancelled, get() will throw a CancellationException wrapping a
167+
// CancellationException, thus we need to unwrap it to maintain the KafkaFuture behaviour.
168+
// see https://bugs.openjdk.org/browse/JDK-8331987
169+
} catch (ExecutionException | CancellationException e) {
167170
maybeThrowCancellationException(e.getCause());
168171
throw e;
169172
}
@@ -178,7 +181,10 @@ public T get(long timeout, TimeUnit unit) throws InterruptedException, Execution
178181
TimeoutException {
179182
try {
180183
return completableFuture.get(timeout, unit);
181-
} catch (ExecutionException e) {
184+
// In Java 23, When a CompletableFuture is cancelled, get() will throw a CancellationException wrapping a
185+
// CancellationException, thus we need to unwrap it to maintain the KafkaFuture behaviour.
186+
// see https://bugs.openjdk.org/browse/JDK-8331987
187+
} catch (ExecutionException | CancellationException e) {
182188
maybeThrowCancellationException(e.getCause());
183189
throw e;
184190
}
@@ -192,6 +198,15 @@ public T get(long timeout, TimeUnit unit) throws InterruptedException, Execution
192198
public T getNow(T valueIfAbsent) throws ExecutionException {
193199
try {
194200
return completableFuture.getNow(valueIfAbsent);
201+
} catch (CancellationException e) {
202+
// In Java 23, When a CompletableFuture is cancelled, getNow() will throw a CancellationException wrapping a
203+
// CancellationException. whereas in Java < 23, it throws a CompletionException directly.
204+
// see https://bugs.openjdk.org/browse/JDK-8331987
205+
if (e.getCause() instanceof CancellationException) {
206+
throw (CancellationException) e.getCause();
207+
} else {
208+
throw e;
209+
}
195210
} catch (CompletionException e) {
196211
maybeThrowCancellationException(e.getCause());
197212
// Note, unlike CompletableFuture#get() which throws ExecutionException, CompletableFuture#getNow()
@@ -247,6 +262,15 @@ public String toString() {
247262
Throwable exception = null;
248263
try {
249264
value = completableFuture.getNow(null);
265+
} catch (CancellationException e) {
266+
// In Java 23, When a CompletableFuture is cancelled, getNow() will throw a CancellationException wrapping a
267+
// CancellationException. whereas in Java < 23, it throws a CompletionException directly.
268+
// see https://bugs.openjdk.org/browse/JDK-8331987
269+
if (e.getCause() instanceof CancellationException) {
270+
exception = e.getCause();
271+
} else {
272+
exception = e;
273+
}
250274
} catch (CompletionException e) {
251275
exception = e.getCause();
252276
} catch (Exception e) {

core/src/test/scala/integration/kafka/api/SaslPlainSslEndToEndAuthorizationTest.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import kafka.utils.TestUtils.isAclSecure
2323
import kafka.zk.ZkData
2424
import org.apache.kafka.common.config.SaslConfigs
2525
import org.apache.kafka.common.config.internals.BrokerSecurityConfigs
26+
import org.apache.kafka.common.internals.SecurityManagerCompatibility
2627
import org.apache.kafka.common.network.ConnectionMode
2728
import org.apache.kafka.common.security.auth._
2829
import org.apache.kafka.common.security.authenticator.DefaultKafkaPrincipalBuilder
@@ -31,9 +32,7 @@ import org.apache.kafka.test.TestSslUtils
3132
import org.junit.jupiter.api.Assertions.{assertEquals, assertTrue}
3233
import org.junit.jupiter.api.Test
3334

34-
import java.security.AccessController
3535
import java.util.{Collections, Optional, Properties}
36-
import javax.security.auth.Subject
3736
import javax.security.auth.callback._
3837
import javax.security.auth.login.AppConfigurationEntry
3938
import scala.collection.Seq
@@ -89,7 +88,7 @@ object SaslPlainSslEndToEndAuthorizationTest {
8988
class TestClientCallbackHandler extends AuthenticateCallbackHandler {
9089
def configure(configs: java.util.Map[String, _], saslMechanism: String, jaasConfigEntries: java.util.List[AppConfigurationEntry]): Unit = {}
9190
def handle(callbacks: Array[Callback]): Unit = {
92-
val subject = Subject.getSubject(AccessController.getContext)
91+
val subject = SecurityManagerCompatibility.get().current()
9392
val username = subject.getPublicCredentials(classOf[String]).iterator().next()
9493
for (callback <- callbacks) {
9594
callback match {

jmh-benchmarks/src/main/java/org/apache/kafka/jmh/util/ByteUtilsBenchmark.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,17 @@
4141
import java.security.SecureRandom;
4242
import java.util.concurrent.TimeUnit;
4343

44-
@OutputTimeUnit(TimeUnit.SECONDS)
45-
@Fork(3)
46-
@Warmup(iterations = 3, time = 1)
47-
@Measurement(iterations = 5, time = 1)
4844
/**
4945
* This benchmark calculates the empirical evidence of different implementation for encoding/decoding a protobuf
5046
* <a href="https://protobuf.dev/programming-guides/encoding/#varints">VarInt</a> and VarLong.
5147
*
5248
* The benchmark uses JMH and calculates results for different sizes of variable length integer. We expect most of the
5349
* usage in Kafka code base to be 1 or 2 byte integers.
5450
*/
51+
@OutputTimeUnit(TimeUnit.SECONDS)
52+
@Fork(3)
53+
@Warmup(iterations = 3, time = 1)
54+
@Measurement(iterations = 5, time = 1)
5555
public class ByteUtilsBenchmark {
5656
private static final int DATA_SET_SAMPLE_SIZE = 16384;
5757

0 commit comments

Comments
 (0)