You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ap...@apache.org on 2023/10/21 15:15:17 UTC

[ignite-3] branch main updated: IGNITE-20703 LeaseUpdaterTest causes a NullPointerException (#2732)

This is an automated email from the ASF dual-hosted git repository.

apolovtsev pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git


The following commit(s) were added to refs/heads/main by this push:
     new de072920c0 IGNITE-20703 LeaseUpdaterTest causes a NullPointerException (#2732)
de072920c0 is described below

commit de072920c0fcae32483e7dbd0c4b169fd7c5c852
Author: Roman Puchkovskiy <ro...@gmail.com>
AuthorDate: Sat Oct 21 19:15:12 2023 +0400

    IGNITE-20703 LeaseUpdaterTest causes a NullPointerException (#2732)
---
 .../apache/ignite/internal/placementdriver/LeaseUpdaterTest.java  | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/modules/placement-driver/src/test/java/org/apache/ignite/internal/placementdriver/LeaseUpdaterTest.java b/modules/placement-driver/src/test/java/org/apache/ignite/internal/placementdriver/LeaseUpdaterTest.java
index ce8df49150..dd1a923bd9 100644
--- a/modules/placement-driver/src/test/java/org/apache/ignite/internal/placementdriver/LeaseUpdaterTest.java
+++ b/modules/placement-driver/src/test/java/org/apache/ignite/internal/placementdriver/LeaseUpdaterTest.java
@@ -100,7 +100,7 @@ public class LeaseUpdaterTest extends BaseIgniteAbstractTest {
     /** Lease updater for tests. */
     private LeaseUpdater leaseUpdater;
     /** Closure to get a lease that is passed in Meta storage. */
-    private Consumer<Lease> renewLeaseConsumer = null;
+    private volatile Consumer<Lease> renewLeaseConsumer = null;
 
     @BeforeEach
     void setUp() {
@@ -121,13 +121,15 @@ public class LeaseUpdaterTest extends BaseIgniteAbstractTest {
 
         lenient().when(metaStorageManager.invoke(any(Condition.class), any(Operation.class), any(Operation.class)))
                 .thenAnswer(invocation -> {
-                    if (renewLeaseConsumer != null) {
+                    Consumer<Lease> leaseConsumer = renewLeaseConsumer;
+
+                    if (leaseConsumer != null) {
                         OperationImpl op = invocation.getArgument(1);
 
                         Lease lease = LeaseBatch.fromBytes(ByteBuffer.wrap(op.value()).order(ByteOrder.LITTLE_ENDIAN)).leases().iterator()
                                 .next();
 
-                        renewLeaseConsumer.accept(lease);
+                        leaseConsumer.accept(lease);
                     }
 
                     return completedFuture(true);