Skip to content

Commit f345481

Browse files
lhotarimanas-ctds
authored andcommitted
[fix][build][branch-4.0] Fix issue in backporting PR apache#25644
The backport of apache#25644 introduced a Java record (`Table<V>`) in `ConcurrentLongHashMap`, which fails to compile on branch-4.0 because the `pulsar-common` module targets Java 8 source compatibility. Records require `-source 16` or higher. Replace the record with an equivalent static nested final class that exposes the same `keys()`, `values()`, and `capacity()` accessors, so all existing call sites continue to work unchanged. (cherry picked from commit 62b04fc)
1 parent dd2bf24 commit f345481

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

pulsar-common/src/main/java/org/apache/pulsar/common/util/collections/ConcurrentLongHashMap.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,29 @@ public interface EntryProcessor<V> {
293293
// previous design had to paper over with Math.min(keys.length, values.length).
294294
@SuppressWarnings("serial")
295295
private static final class Section<V> extends StampedLock {
296-
private record Table<V>(long[] keys, V[] values, int capacity) { }
296+
private static final class Table<V> {
297+
private final long[] keys;
298+
private final V[] values;
299+
private final int capacity;
300+
301+
Table(long[] keys, V[] values, int capacity) {
302+
this.keys = keys;
303+
this.values = values;
304+
this.capacity = capacity;
305+
}
306+
307+
long[] keys() {
308+
return keys;
309+
}
310+
311+
V[] values() {
312+
return values;
313+
}
314+
315+
int capacity() {
316+
return capacity;
317+
}
318+
}
297319

298320
// Section is Serializable only by inheritance from StampedLock; never actually serialized.
299321
@SuppressFBWarnings("SE_BAD_FIELD")

0 commit comments

Comments
 (0)