chia7712 commented on code in PR #20751:
URL: https://github.com/apache/kafka/pull/20751#discussion_r2478092812
##########
clients/src/test/java/org/apache/kafka/common/header/internals/RecordHeadersTest.java:
##########
@@ -265,4 +273,46 @@ static void assertHeader(String key, String value, Header
actual) {
assertArrayEquals(value.getBytes(), actual.value());
}
+ private void assertRecordHeaderReadThreadSafe(RecordHeader header) throws
Exception {
+ int threadCount = 32;
+ CountDownLatch startLatch = new CountDownLatch(1);
+ AtomicBoolean raceDetected = new AtomicBoolean(false);
+
+ var futures = IntStream.range(0, threadCount)
+ .mapToObj(i -> CompletableFuture.runAsync(() -> {
+ try {
+ startLatch.await();
+ header.key();
+ header.value();
+ } catch (NullPointerException e) {
+ raceDetected.set(true);
Review Comment:
we don't need `raceDetected`, since `join` could show the error.
##########
clients/src/test/java/org/apache/kafka/common/header/internals/RecordHeadersTest.java:
##########
@@ -265,4 +273,46 @@ static void assertHeader(String key, String value, Header
actual) {
assertArrayEquals(value.getBytes(), actual.value());
}
+ private void assertRecordHeaderReadThreadSafe(RecordHeader header) throws
Exception {
Review Comment:
`Exception` is unnecessary
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]