[
https://issues.apache.org/jira/browse/IGNITE-9197?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16571256#comment-16571256
]
Alexey Kukushkin commented on IGNITE-9197:
------------------------------------------
ANALYSIS
ClientQueryCursor#hasNext() returns "true" if the first page has not yet been
queried. This is wrong since we return "true" even if the first page is empty.
SOLUTION
ClientQueryCursor#hasNext() must force getting first page to check if the first
page is empty.
That requires QueryPager interface to expose information on whether the first
page has been extracted.
> Java thin client querying empty table results in NoSuchElementException
> -----------------------------------------------------------------------
>
> Key: IGNITE-9197
> URL: https://issues.apache.org/jira/browse/IGNITE-9197
> Project: Ignite
> Issue Type: Bug
> Components: thin client
> Affects Versions: 2.6
> Reporter: Alexey Kukushkin
> Assignee: Alexey Kukushkin
> Priority: Critical
> Fix For: 2.7
>
>
> +*Reproducer*+
> {code:java}
> @Test
> public void testGettingEmptyResultWhenQueryingEmptyTable() throws Exception {
> try (Ignite ignored = Ignition.start(Config.getServerConfiguration());
> IgniteClient client = Ignition.startClient(new
> ClientConfiguration().setAddresses(Config.SERVER))
> ) {
> final String TBL = "Person";
> client.query(
> new SqlFieldsQuery("CREATE TABLE IF NOT EXISTS " + TBL + " (id
> INT PRIMARY KEY, name VARCHAR)")
> ).getAll();
> List<List<?>> res = client.query(new SqlFieldsQuery("SELECT * FROM "
> + TBL)).getAll();
> assertNotNull(res);
> assertEquals(0, res.size());
> }
> }
> {code}
> *Expected*
> The test above should pass
> *Actual*
> java.util.NoSuchElementException
> at java.util.ArrayList$Itr.next(ArrayList.java:862)
> at
> org.apache.ignite.internal.client.thin.ClientQueryCursor$1.next(ClientQueryCursor.java:87)
> at
> org.apache.ignite.internal.client.thin.ClientQueryCursor.getAll(ClientQueryCursor.java:45)
> at
> org.apache.ignite.client.FunctionalQueryTest.testGettingEmptyResultWhenQueryingEmptyTable(FunctionalQueryTest.java:171)
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)