You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@geode.apache.org by GitBox <gi...@apache.org> on 2022/04/28 00:50:00 UTC

[GitHub] [geode] DonalEvans commented on a diff in pull request #7631: GEODE-10261: VMProvider.invokeAsync uses appropriate parameterization.

DonalEvans commented on code in PR #7631:
URL: https://github.com/apache/geode/pull/7631#discussion_r860339147


##########
geode-core/src/distributedTest/java/org/apache/geode/cache/query/internal/index/InitializeIndexEntryDestroyQueryDUnitTest.java:
##########
@@ -141,7 +141,8 @@ public void testConcurrentRemoveIndexAndQueryOnPR() {
 
   }
 
-  private void waitForAsyncThreadsToComplete(AsyncInvocation asyInvk0, AsyncInvocation asyInvk1) {
+  private void waitForAsyncThreadsToComplete(AsyncInvocation asyInvk0,

Review Comment:
   This first `AsyncInvoaction` can also be `AsyncInvocation<Void>`



##########
geode-core/src/distributedTest/java/org/apache/geode/management/DiskManagementDUnitTest.java:
##########
@@ -394,7 +394,7 @@ private MemberMXBean awaitMemberMXBeanProxy(final DistributedMember member) {
     return service.getMBeanProxy(objectName, MemberMXBean.class);
   }
 
-  private void await(final AsyncInvocation createPersistentRegionAsync)
+  private void await(final AsyncInvocation<?> createPersistentRegionAsync)

Review Comment:
   This can be `AsyncInvocation<Void>`



##########
geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/tests/BasicDistributedTest.java:
##########
@@ -154,8 +154,9 @@ public void testRemoteInvokeAsync() throws Exception {
     String name = getUniqueName();
     String value = "Hello";
 
-    AsyncInvocation async1 = vm0.invokeAsync(() -> remoteBind(name, value)).join().checkException();
-    AsyncInvocation async2 =
+    AsyncInvocation<?> async1 =
+        vm0.invokeAsync(() -> remoteBind(name, value)).join().checkException();
+    AsyncInvocation<?> async2 =

Review Comment:
   This can be:
   ```
       AsyncInvocation<Void> async1 =
           vm0.<Void>invokeAsync(() -> remoteBind(name, value)).join().checkException();
       AsyncInvocation<Void> async2 =
           vm0.<Void>invokeAsync(() -> remoteValidateBind(name, value)).join().checkException();
   ```



##########
geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/tests/VMDistributedTest.java:
##########
@@ -89,7 +89,7 @@ public void testReturnValue() throws Exception {
     final Host host = Host.getHost(0);
     final VM vm = host.getVM(0);
     // Assert class static invocation works
-    AsyncInvocation a1 = vm.invokeAsync(VMDistributedTest::getAndIncStaticCount);
+    AsyncInvocation<?> a1 = vm.invokeAsync(VMDistributedTest::getAndIncStaticCount);

Review Comment:
   This class is kind of a mess what with all the deprecated calls and use of JUnit assertions rather than AssertJ, but this would probably be better as:
   ```
   
       AsyncInvocation<Integer> a1 = vm.invokeAsync(VMDistributedTest::getAndIncStaticCount);
       a1.join();
       assertEquals(0, (long) a1.getReturnValue());
       // Assert class static invocation with args works
       a1 = vm.invokeAsync(() -> incrementStaticCount(2));
       a1.join();
       assertEquals(3, (long) a1.getReturnValue());
       // Assert that previous values are not returned when invoking method w/ no return val
       a1 = vm.invokeAsync(VMDistributedTest::incStaticCount);
       a1.join();
       assertNull(a1.getReturnValue());
       // Assert that previous null returns are over-written
       a1 = vm.invokeAsync(VMDistributedTest::getAndIncStaticCount);
       a1.join();
       assertEquals(4, (long) a1.getReturnValue());
   
       // Assert object method invocation works with zero arg method
       final VMTestObject o = new VMTestObject(0);
       a1 = vm.invokeAsync(o, "incrementAndGet", new Object[] {});
       a1.join();
       assertEquals(1, (long) a1.getReturnValue());
   ```
   so that we can use a definite type rather than `<?>`



##########
geode-core/src/distributedTest/java/org/apache/geode/internal/cache/partitioned/PersistentColocatedPartitionedRegionDistributedTest.java:
##########
@@ -123,7 +123,7 @@ public class PersistentColocatedPartitionedRegionDistributedTest implements Seri
   private static volatile InternalCache cache;
   private static volatile CountDownLatch latch;
 
-  private final transient List<AsyncInvocation<Void>> asyncInvocations = new ArrayList<>();
+  private final transient List<AsyncInvocation<?>> asyncInvocations = new ArrayList<>();

Review Comment:
   I don't think the changes from `AsyncInvocation<Void>` to `AsyncInvocation<?>` are necessary here.



##########
geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PutAllGlobalDUnitTest.java:
##########
@@ -159,55 +159,56 @@ public void testputAllGlobalRemoteVM() throws Throwable {
 
     final int socketPort = vm0.invoke(PutAllGlobalDUnitTest::openSocket);
 
-    AsyncInvocation async1 = vm0.invokeAsync(PutAllGlobalDUnitTest::putAllMethod);
-
-    AsyncInvocation async2 = vm1.invokeAsync(new CacheSerializableRunnable("put from another vm") {
-      @Override
-      public void run2() throws CacheException {
-        long endTime = System.currentTimeMillis() + 5000;
-        boolean connected = false;
-        while (!connected && (System.currentTimeMillis() < endTime)) {
-          try {
-            Socket sock = new Socket(InetAddress.getLocalHost(), socketPort);
-            connected = true;
-            sock.close();
-          } catch (IOException ioe) {
-            // ignored - will time out using 'endTime'
+    AsyncInvocation<Void> async1 = vm0.invokeAsync(PutAllGlobalDUnitTest::putAllMethod);
+
+    AsyncInvocation<Void> async2 =
+        vm1.invokeAsync(new CacheSerializableRunnable("put from another vm") {
+          @Override
+          public void run2() throws CacheException {

Review Comment:
   Use of a deprecated class can be avoided here by making this:
   ```
       AsyncInvocation<Void> async2 =
           vm1.invokeAsync("put from another vm", () -> {
             long endTime = System.currentTimeMillis() + 5000;
   ...
   ```
   and removing the extra curly brace on line 210



-- 
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@geode.apache.org

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