This is an automated email from the ASF dual-hosted git repository.
ptupitsyn 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 97f4b772fc IGNITE-18650 Fix NullPointerException in
TableManager.assignments (#1621)
97f4b772fc is described below
commit 97f4b772fcf9aab40bd56f552b3932fbe440555f
Author: Pavel Tupitsyn <[email protected]>
AuthorDate: Thu Feb 2 17:43:46 2023 +0200
IGNITE-18650 Fix NullPointerException in TableManager.assignments (#1621)
Fix NullPointerException when assignments are requested for a table that no
longer exists.
---
.../runner/app/client/ItThinClientConnectionTest.java | 17 +++++++++++++++++
.../ignite/internal/table/IgniteTablesInternal.java | 2 ++
.../ignite/internal/table/distributed/TableManager.java | 8 +++++++-
3 files changed, 26 insertions(+), 1 deletion(-)
diff --git
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItThinClientConnectionTest.java
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItThinClientConnectionTest.java
index 47b35de673..0c28144347 100644
---
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItThinClientConnectionTest.java
+++
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItThinClientConnectionTest.java
@@ -20,12 +20,16 @@ package org.apache.ignite.internal.runner.app.client;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.startsWith;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.List;
import org.apache.ignite.client.IgniteClient;
import org.apache.ignite.internal.testframework.WorkDirectoryExtension;
+import org.apache.ignite.lang.ErrorGroups.Client;
+import org.apache.ignite.lang.IgniteException;
import org.apache.ignite.network.ClusterNode;
+import org.apache.ignite.sql.Session;
import org.apache.ignite.table.RecordView;
import org.apache.ignite.table.Table;
import org.apache.ignite.table.Tuple;
@@ -72,4 +76,17 @@ public class ItThinClientConnectionTest extends
ItAbstractThinClientTest {
}
}
}
+
+ @SuppressWarnings("resource")
+ @Test
+ void testAccessDroppedTableThrowsTableDoesNotExistsError() {
+ Session session = client().sql().createSession();
+ session.execute(null, "CREATE TABLE IF NOT EXISTS DELME (key INTEGER
PRIMARY KEY)");
+
+ var table = client().tables().table("DELME");
+ session.execute(null, "DROP TABLE DELME");
+
+ IgniteException ex = assertThrows(IgniteException.class, () ->
table.recordView(Integer.class).delete(null, 1));
+ assertEquals(Client.TABLE_ID_NOT_FOUND_ERR, ex.code(),
ex.getMessage());
+ }
}
diff --git
a/modules/table/src/main/java/org/apache/ignite/internal/table/IgniteTablesInternal.java
b/modules/table/src/main/java/org/apache/ignite/internal/table/IgniteTablesInternal.java
index 5e243ea0ae..cc44042e72 100644
---
a/modules/table/src/main/java/org/apache/ignite/internal/table/IgniteTablesInternal.java
+++
b/modules/table/src/main/java/org/apache/ignite/internal/table/IgniteTablesInternal.java
@@ -24,6 +24,7 @@ import java.util.function.Consumer;
import org.apache.ignite.lang.IgniteException;
import org.apache.ignite.lang.NodeStoppingException;
import org.apache.ignite.table.manager.IgniteTables;
+import org.jetbrains.annotations.Nullable;
/**
* Internal tables facade provides low-level methods for table operations.
@@ -86,6 +87,7 @@ public interface IgniteTablesInternal extends IgniteTables {
* @param tableId Unique id of a table.
* @return List of the current assignments.
*/
+ @Nullable
List<String> assignments(UUID tableId) throws NodeStoppingException;
/**
diff --git
a/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java
b/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java
index e3cd05a9d2..d1a483094f 100644
---
a/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java
+++
b/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java
@@ -1049,7 +1049,13 @@ public class TableManager extends Producer<TableEvent,
TableEventParameters> imp
throw new NodeStoppingException();
}
try {
- return table(tableId).internalTable().assignments();
+ TableImpl table = table(tableId);
+
+ if (table == null) {
+ return null;
+ }
+
+ return table.internalTable().assignments();
} finally {
busyLock.leaveBusy();
}