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


##########
geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PartitionedRegionSingleHopDUnitTest.java:
##########
@@ -919,21 +897,22 @@ public void testClientMetadataForPersistentPrs() throws 
Exception {
 
     int locatorPort = DUnitEnv.get().getLocatorPort();
 
-    vm0.invoke(() -> createServer("disk", -1, 3, 4));
-    vm1.invoke(() -> createServer("disk", -1, 3, 4));
-    vm2.invoke(() -> createServer("disk", -1, 3, 4));
-    vm3.invoke(() -> createServer("disk", -1, 3, 4));
+    vm0.invoke((SerializableCallableIF<Integer>) this::createServer);
+    vm1.invoke((SerializableCallableIF<Integer>) this::createServer);
+    vm2.invoke((SerializableCallableIF<Integer>) this::createServer);
+    vm3.invoke((SerializableCallableIF<Integer>) this::createServer);

Review Comment:
   If there was just one `createServer()` method in the class (or the zero-arg 
version of the method had a unique name) then we wouldn't need the cast here, 
but since there are multiple methods with different signatures but the same 
name, omitting the cast and just using a method reference results in ambiguity, 
since the compiler doesn't know which one you mean and throws an error.
   
   It's true that method references are preferred in Java, but the performance 
optimizations are negligible in a test, and more readable code is a greater 
benefit here, I think. IntelliJ doesn't even highlight the lambda as 
replaceable with a method reference if you make this change, because I guess it 
knows that the compiler will complain if you do.



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

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

Reply via email to