You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by lh...@apache.org on 2026/09/14 14:18:15 UTC
(pulsar) 13/17: [fix][build][branch-4.0] Fix Java 8 compile error in backported TableViewImplTest
This is an automated email from the ASF dual-hosted git repository.
lhotari pushed a commit to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/pulsar.git
commit d07c8abd4638138b122b9b1279338abba0ded6eb
Author: Lari Hotari <lh...@apache.org>
AuthorDate: Mon Sep 14 13:14:40 2026 +0300
[fix][build][branch-4.0] Fix Java 8 compile error in backported TableViewImplTest
The backport of #26566 (branch-4.0 commit 145067529be, cherry-picked from
172b7c32c71 via branch-4.2 commit 078f7b2ab9d) added
testRefreshWaitsForMessageToBeApplied, which uses `var` and `List.of(...)`.
The pulsar-client module on branch-4.0 is compiled with
pulsar.client.compiler.release=8, so the test sources fail to compile
("cannot find symbol: class var", "method of()").
Replace `var` with explicit types and `List.of(...)` with
`Collections.emptyList()` / `Collections.singletonList(...)`. The test
logic is unchanged.
Validation: TableViewImplTest passes (3 tests, both data-provider variants).
---
.../org/apache/pulsar/client/impl/TableViewImplTest.java | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/pulsar-client/src/test/java/org/apache/pulsar/client/impl/TableViewImplTest.java b/pulsar-client/src/test/java/org/apache/pulsar/client/impl/TableViewImplTest.java
index 9761cc9aed31..02f4365e8a73 100644
--- a/pulsar-client/src/test/java/org/apache/pulsar/client/impl/TableViewImplTest.java
+++ b/pulsar-client/src/test/java/org/apache/pulsar/client/impl/TableViewImplTest.java
@@ -29,11 +29,12 @@ import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
-import java.util.List;
+import java.util.Collections;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.pulsar.client.api.CryptoKeyReader;
@@ -42,7 +43,9 @@ import org.apache.pulsar.client.api.Reader;
import org.apache.pulsar.client.api.ReaderBuilder;
import org.apache.pulsar.client.api.Schema;
import org.apache.pulsar.client.api.TableView;
+import org.apache.pulsar.client.api.TopicMessageId;
import org.apache.pulsar.common.topics.TopicCompactionStrategy;
+import org.mockito.MockedStatic;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@@ -88,8 +91,8 @@ public class TableViewImplTest {
when(reader.closeAsync()).thenReturn(CompletableFuture.completedFuture(null));
TopicMessageIdImpl messageId = new TopicMessageIdImpl(topic, new MessageIdImpl(1, 0, -1));
when(reader.getLastMessageIdsAsync()).thenReturn(
- CompletableFuture.completedFuture(List.of()),
- CompletableFuture.completedFuture(List.of(messageId)));
+ CompletableFuture.completedFuture(Collections.<TopicMessageId>emptyList()),
+ CompletableFuture.completedFuture(Collections.<TopicMessageId>singletonList(messageId)));
CompletableFuture<Message<String>> nextMessage = new CompletableFuture<>();
when(reader.readNextAsync()).thenReturn(nextMessage, new CompletableFuture<>());
TableViewConfigurationData conf = new TableViewConfigurationData();
@@ -97,7 +100,7 @@ public class TableViewImplTest {
TopicCompactionStrategy<String> strategy = mock(TopicCompactionStrategy.class);
when(strategy.shouldKeepLeft(any(), any())).thenReturn(skipped);
TableViewImpl<String> tableView;
- try (var strategies = mockStatic(TopicCompactionStrategy.class)) {
+ try (MockedStatic<TopicCompactionStrategy> strategies = mockStatic(TopicCompactionStrategy.class)) {
strategies.when(() -> TopicCompactionStrategy.load(TopicCompactionStrategy.TABLE_VIEW_TAG, null))
.thenReturn(strategy);
tableView = new TableViewImpl<>(client, Schema.STRING, conf);
@@ -125,10 +128,10 @@ public class TableViewImplTest {
});
ExecutorService executor = Executors.newSingleThreadExecutor();
try {
- var delivery = executor.submit(() -> nextMessage.complete(message));
+ Future<Boolean> delivery = executor.submit(() -> nextMessage.complete(message));
assertTrue(decoding.await(5, TimeUnit.SECONDS));
assertNull(tableView.get("key"));
- var refresh = tableView.refreshAsync();
+ CompletableFuture<Void> refresh = tableView.refreshAsync();
assertFalse(refresh.isDone(), "Refresh must not finish before the message updates the table");
applyMessage.countDown();
delivery.get(5, TimeUnit.SECONDS);