You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2022/11/21 08:15:54 UTC

[GitHub] [ignite-3] rpuch opened a new pull request, #1358: IGNITE-18049 Cursor#close() should not declare any exceptions in throws clause

rpuch opened a new pull request, #1358:
URL: https://github.com/apache/ignite-3/pull/1358

   https://issues.apache.org/jira/browse/IGNITE-18049


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [ignite-3] rpuch commented on a diff in pull request #1358: IGNITE-18049 Cursor#close() should not declare any exceptions in throws clause

Posted by GitBox <gi...@apache.org>.
rpuch commented on code in PR #1358:
URL: https://github.com/apache/ignite-3/pull/1358#discussion_r1027879620


##########
modules/rest/openapi/openapi.yaml:
##########
@@ -6,7 +6,7 @@ info:
   license:
     name: Apache 2.0
     url: https://ignite.apache.org
-  version: 3.0.0-SNAPSHOT
+  version: 3.0.0-alpha

Review Comment:
   Reverted thechange



##########
modules/rest/openapi/openapi.yaml:
##########
@@ -6,7 +6,7 @@ info:
   license:
     name: Apache 2.0
     url: https://ignite.apache.org
-  version: 3.0.0-SNAPSHOT
+  version: 3.0.0-alpha

Review Comment:
   Reverted the change



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [ignite-3] ibessonov commented on a diff in pull request #1358: IGNITE-18049 Cursor#close() should not declare any exceptions in throws clause

Posted by GitBox <gi...@apache.org>.
ibessonov commented on code in PR #1358:
URL: https://github.com/apache/ignite-3/pull/1358#discussion_r1027850174


##########
modules/core/src/test/java/org/apache/ignite/internal/util/CursorTest.java:
##########
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.util;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.endsWith;
+import static org.hamcrest.Matchers.is;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.util.Iterator;
+import java.util.List;
+import org.junit.jupiter.api.Test;
+
+class CursorTest {
+    @Test
+    void bareIteratorAdapterProvidesDataFromIterator() throws Exception {
+        try (Cursor<Integer> cursor = Cursor.fromBareIterator(List.of(1, 2).iterator())) {
+            assertThat(cursor.next(), is(1));
+            assertThat(cursor.next(), is(2));
+        }
+    }
+
+    @Test
+    void fromBareIteratorThrowsOnCloseableIterator() {
+        Exception ex = assertThrows(IllegalArgumentException.class, () -> Cursor.fromBareIterator(mock(CloseableIterator.class)));
+
+        assertThat(ex.getMessage(), endsWith(" implements AutoCloseable, while Cursor#fromBareIterator() "
+                + "only supports non-closeable iterators. Please refer to Cursor#fromCloseableIterator()."));
+    }
+
+    @Test
+    void closeableIteratorAdapterProvidesDataFromIterator() throws Exception {
+        CloseableIterator iterator = mock(CloseableIterator.class);
+
+        when(iterator.hasNext()).thenReturn(true, true, false);
+        when(iterator.next()).thenReturn(1, 2);
+
+        try (Cursor<Integer> cursor = Cursor.fromCloseableIterator(iterator)) {
+            assertThat(cursor.next(), is(1));
+            assertThat(cursor.next(), is(2));
+        }
+    }
+
+    @Test
+    void closeableIteratorAdapterClosesIteratorOnClose() throws Exception {
+        CloseableIterator iterator = mock(CloseableIterator.class);
+        Cursor<?> cursor = Cursor.fromCloseableIterator(iterator);
+
+        cursor.close();
+
+        verify(iterator).close();
+    }
+
+    private interface CloseableIterator extends Iterator<Integer>, AutoCloseable {
+        @Override
+        void close();
+    }
+}

Review Comment:
   Please add empty line at the end



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [ignite-3] ibessonov merged pull request #1358: IGNITE-18049 Cursor#close() should not declare any exceptions in throws clause

Posted by GitBox <gi...@apache.org>.
ibessonov merged PR #1358:
URL: https://github.com/apache/ignite-3/pull/1358


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [ignite-3] rpuch commented on a diff in pull request #1358: IGNITE-18049 Cursor#close() should not declare any exceptions in throws clause

Posted by GitBox <gi...@apache.org>.
rpuch commented on code in PR #1358:
URL: https://github.com/apache/ignite-3/pull/1358#discussion_r1027863211


##########
modules/rest/openapi/openapi.yaml:
##########
@@ -6,7 +6,7 @@ info:
   license:
     name: Apache 2.0
     url: https://ignite.apache.org
-  version: 3.0.0-SNAPSHOT
+  version: 3.0.0-alpha

Review Comment:
   Oh... this is an auto-generated file, IIRC, we must commit as soon as it generates with a new version. I committed it accidentally, but it probably needs to be committed. I will ask the guys in Slack.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [ignite-3] ibessonov commented on a diff in pull request #1358: IGNITE-18049 Cursor#close() should not declare any exceptions in throws clause

Posted by GitBox <gi...@apache.org>.
ibessonov commented on code in PR #1358:
URL: https://github.com/apache/ignite-3/pull/1358#discussion_r1027849883


##########
modules/rest/openapi/openapi.yaml:
##########
@@ -6,7 +6,7 @@ info:
   license:
     name: Apache 2.0
     url: https://ignite.apache.org
-  version: 3.0.0-SNAPSHOT
+  version: 3.0.0-alpha

Review Comment:
   What's this?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org