You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by pt...@apache.org on 2022/01/17 08:08:12 UTC
[ignite-3] branch main updated: IGNITE-16303 Fix MessageTypeException in ClientTables.table when table does not exist (#555)
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 5cf1b83 IGNITE-16303 Fix MessageTypeException in ClientTables.table when table does not exist (#555)
5cf1b83 is described below
commit 5cf1b837fa8dc55e88af896b25043d5a45689c74
Author: Pavel Tupitsyn <pt...@apache.org>
AuthorDate: Mon Jan 17 11:08:09 2022 +0300
IGNITE-16303 Fix MessageTypeException in ClientTables.table when table does not exist (#555)
---
.../ignite/internal/client/table/ClientTables.java | 2 +-
.../java/org/apache/ignite/client/ClientTablesTest.java | 16 ++++++++++++++++
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientTables.java b/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientTables.java
index df9981a..c4601ec 100644
--- a/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientTables.java
+++ b/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientTables.java
@@ -123,6 +123,6 @@ public class ClientTables implements IgniteTables {
Objects.requireNonNull(name);
return ch.serviceAsync(ClientOp.TABLE_GET, w -> w.out().packString(name),
- r -> new ClientTable(ch, r.in().unpackIgniteUuid(), name));
+ r -> r.in().tryUnpackNil() ? null : new ClientTable(ch, r.in().unpackIgniteUuid(), name));
}
}
diff --git a/modules/client/src/test/java/org/apache/ignite/client/ClientTablesTest.java b/modules/client/src/test/java/org/apache/ignite/client/ClientTablesTest.java
index 2a6c114..60c6c6b 100644
--- a/modules/client/src/test/java/org/apache/ignite/client/ClientTablesTest.java
+++ b/modules/client/src/test/java/org/apache/ignite/client/ClientTablesTest.java
@@ -18,6 +18,7 @@
package org.apache.ignite.client;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -57,6 +58,21 @@ public class ClientTablesTest extends AbstractClientTest {
}
@Test
+ public void testTableReturnsInstanceWhenExists() {
+ server.tables().createTable(DEFAULT_TABLE, null);
+ Table table = client.tables().table(DEFAULT_TABLE);
+
+ assertEquals(DEFAULT_TABLE, table.name());
+ }
+
+ @Test
+ public void testTableReturnsNullWhenDoesNotExist() {
+ Table table = client.tables().table("non-existent-table");
+
+ assertNull(table);
+ }
+
+ @Test
@Disabled("IGNITE-15179")
public void testCreateTable() {
var clientTable = client.tables().createTable("t1", t -> t.changeReplicas(2));