This is an automated email from the ASF dual-hosted git repository.

burcham pushed a commit to branch support/1.13
in repository https://gitbox.apache.org/repos/asf/geode.git

commit 986334e9198a1756b839d0d13028f4a846ea29b5
Author: Bill Burcham <bill.burc...@gmail.com>
AuthorDate: Thu Nov 5 12:28:55 2020 -0800

    Revert "GEODE-8136: Move UncheckedUtils to geode-common (#5123)"
    
    This reverts commit 10af7ea015ec85ef02b2e972c7a3dd3ec23bcb7f.
---
 .../geode/util/internal/UncheckedUtilsTest.java    | 60 ----------------------
 .../cache/PartitionedRegionSingleHopDUnitTest.java | 14 ++---
 ...istributedRegionFunctionExecutionDUnitTest.java | 59 ++++++++++++++-------
 ...oningWithColocationAndPersistenceDUnitTest.java | 12 ++---
 .../FunctionExecutionOnLonerRegressionTest.java    | 27 ++++++++--
 .../client/internal/ClientMetadataService.java     |  4 +-
 .../geode/internal/cache/GemFireCacheImpl.java     | 49 ++++++++++++++----
 .../cache/InternalCacheForClientAccess.java        |  6 +--
 .../apache/geode/internal/cache/LocalRegion.java   |  7 +--
 .../cache/execute/util/TypedFunctionService.java   | 37 -------------
 .../tier/sockets/CacheClientProxyFactory.java      |  4 +-
 .../geode/internal/cache/util}/UncheckedUtils.java | 19 +++----
 .../internal/ClusterAlertMessagingTest.java        |  6 +--
 .../apache/geode/internal/tcp/TCPConduitTest.java  |  4 +-
 14 files changed, 134 insertions(+), 174 deletions(-)

diff --git 
a/geode-common/src/test/java/org/apache/geode/util/internal/UncheckedUtilsTest.java
 
b/geode-common/src/test/java/org/apache/geode/util/internal/UncheckedUtilsTest.java
deleted file mode 100644
index 7c282b7..0000000
--- 
a/geode-common/src/test/java/org/apache/geode/util/internal/UncheckedUtilsTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.geode.util.internal;
-
-import static org.apache.geode.util.internal.UncheckedUtils.uncheckedCast;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.catchThrowable;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.junit.Test;
-
-@SuppressWarnings("unchecked")
-public class UncheckedUtilsTest {
-
-  @Test
-  public void uncheckedCast_rawList_empty() {
-    List rawList = new ArrayList();
-
-    List<String> value = uncheckedCast(rawList);
-
-    assertThat(value).isSameAs(rawList);
-  }
-
-  @Test
-  public void uncheckedCast_rawList_nonEmpty() {
-    List rawList = new ArrayList();
-    rawList.add("1");
-    rawList.add("2");
-
-    List<String> value = uncheckedCast(rawList);
-
-    assertThat(value).isSameAs(rawList);
-  }
-
-  @Test
-  public void uncheckedCast_rawList_wrongTypes() {
-    List rawList = new ArrayList();
-    rawList.add(1);
-    rawList.add(2);
-    List<String> wrongType = uncheckedCast(rawList);
-
-    Throwable thrown = catchThrowable(() -> wrongType.get(0));
-
-    assertThat(thrown).isInstanceOf(ClassCastException.class);
-  }
-}
diff --git 
a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PartitionedRegionSingleHopDUnitTest.java
 
b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PartitionedRegionSingleHopDUnitTest.java
index 43019bf..943c503 100755
--- 
a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PartitionedRegionSingleHopDUnitTest.java
+++ 
b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PartitionedRegionSingleHopDUnitTest.java
@@ -22,6 +22,7 @@ import static org.apache.geode.cache.RegionShortcut.PARTITION;
 import static org.apache.geode.cache.RegionShortcut.PARTITION_PERSISTENT;
 import static 
org.apache.geode.distributed.ConfigurationProperties.ENABLE_CLUSTER_CONFIGURATION;
 import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
+import static org.apache.geode.internal.cache.util.UncheckedUtils.cast;
 import static 
org.apache.geode.internal.lang.SystemPropertyHelper.GEMFIRE_PREFIX;
 import static 
org.apache.geode.management.ManagementService.getExistingManagementService;
 import static org.apache.geode.test.awaitility.GeodeAwaitility.await;
@@ -31,7 +32,6 @@ import static org.apache.geode.test.dunit.VM.getController;
 import static org.apache.geode.test.dunit.VM.getVM;
 import static org.apache.geode.test.dunit.VM.getVMId;
 import static 
org.apache.geode.test.dunit.rules.DistributedRule.getDistributedSystemProperties;
-import static org.apache.geode.util.internal.UncheckedUtils.uncheckedCast;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
 
@@ -76,6 +76,7 @@ import 
org.apache.geode.cache.client.internal.ClientPartitionAdvisor;
 import org.apache.geode.cache.client.internal.InternalClientCache;
 import org.apache.geode.cache.execute.FunctionAdapter;
 import org.apache.geode.cache.execute.FunctionContext;
+import org.apache.geode.cache.execute.FunctionService;
 import org.apache.geode.cache.execute.RegionFunctionContext;
 import org.apache.geode.cache.server.CacheServer;
 import org.apache.geode.distributed.LocatorLauncher;
@@ -83,7 +84,6 @@ import org.apache.geode.distributed.ServerLauncher;
 import org.apache.geode.distributed.internal.ServerLocation;
 import org.apache.geode.internal.cache.BucketAdvisor.ServerBucketProfile;
 import 
org.apache.geode.internal.cache.execute.InternalFunctionInvocationTargetException;
-import org.apache.geode.internal.cache.execute.util.TypedFunctionService;
 import org.apache.geode.management.ManagementService;
 import org.apache.geode.management.membership.MembershipEvent;
 import 
org.apache.geode.management.membership.UniversalMembershipListenerAdapter;
@@ -1336,22 +1336,22 @@ public class PartitionedRegionSingleHopDUnitTest 
implements Serializable {
   }
 
   private void executeFunctions(Region<Object, Object> region) {
-    TypedFunctionService.onRegion(region)
+    cast(FunctionService.onRegion(region))
         .withFilter(filter(0))
         .execute(new PutFunction())
         .getResult();
 
-    TypedFunctionService.onRegion(region)
+    cast(FunctionService.onRegion(region))
         .withFilter(filter(0, 1))
         .execute(new PutFunction())
         .getResult();
 
-    TypedFunctionService.onRegion(region)
+    cast(FunctionService.onRegion(region))
         .withFilter(filter(0, 1, 2, 3))
         .execute(new PutFunction())
         .getResult();
 
-    TypedFunctionService.onRegion(region)
+    cast(FunctionService.onRegion(region))
         .execute(new PutFunction())
         .getResult();
   }
@@ -1389,7 +1389,7 @@ public class PartitionedRegionSingleHopDUnitTest 
implements Serializable {
   }
 
   private InternalCache getInternalCache(ServerLauncher serverLauncher) {
-    return uncheckedCast(serverLauncher.getCache());
+    return cast(serverLauncher.getCache());
   }
 
   private void waitForLocalBucketsCreation() {
diff --git 
a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/execute/DistributedRegionFunctionExecutionDUnitTest.java
 
b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/execute/DistributedRegionFunctionExecutionDUnitTest.java
index b308b20..b95a68b 100755
--- 
a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/execute/DistributedRegionFunctionExecutionDUnitTest.java
+++ 
b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/execute/DistributedRegionFunctionExecutionDUnitTest.java
@@ -22,13 +22,13 @@ import static 
org.apache.geode.distributed.ConfigurationProperties.NAME;
 import static 
org.apache.geode.distributed.ConfigurationProperties.SECURITY_CLIENT_AUTHENTICATOR;
 import static 
org.apache.geode.distributed.ConfigurationProperties.SECURITY_CLIENT_AUTH_INIT;
 import static 
org.apache.geode.distributed.ConfigurationProperties.SERIALIZABLE_OBJECT_FILTER;
+import static 
org.apache.geode.internal.cache.execute.DistributedRegionFunctionExecutionDUnitTest.UncheckedUtils.cast;
 import static org.apache.geode.test.awaitility.GeodeAwaitility.getTimeout;
 import static org.apache.geode.test.dunit.IgnoredException.addIgnoredException;
 import static org.apache.geode.test.dunit.VM.getController;
 import static org.apache.geode.test.dunit.VM.getVM;
 import static org.apache.geode.test.dunit.VM.toArray;
 import static org.apache.geode.util.internal.GeodeGlossary.GEMFIRE_PREFIX;
-import static org.apache.geode.util.internal.UncheckedUtils.uncheckedCast;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.catchThrowable;
 
@@ -59,6 +59,7 @@ import org.apache.geode.cache.client.Pool;
 import org.apache.geode.cache.client.PoolFactory;
 import org.apache.geode.cache.client.PoolManager;
 import org.apache.geode.cache.client.internal.InternalClientCache;
+import org.apache.geode.cache.execute.Execution;
 import org.apache.geode.cache.execute.Function;
 import org.apache.geode.cache.execute.FunctionContext;
 import org.apache.geode.cache.execute.FunctionException;
@@ -69,7 +70,6 @@ import org.apache.geode.cache.execute.ResultCollector;
 import org.apache.geode.cache.server.CacheServer;
 import org.apache.geode.distributed.internal.InternalDistributedSystem;
 import org.apache.geode.internal.cache.InternalCache;
-import org.apache.geode.internal.cache.execute.util.TypedFunctionService;
 import org.apache.geode.security.templates.DummyAuthenticator;
 import org.apache.geode.security.templates.UserPasswordAuthInit;
 import org.apache.geode.test.dunit.AsyncInvocation;
@@ -257,7 +257,7 @@ public class DistributedRegionFunctionExecutionDUnitTest 
implements Serializable
     empty.invoke(() -> populateRegion(200));
 
     AsyncInvocation executeFunctionInReplicate1 = replicate1.invokeAsync(() -> 
{
-      ResultCollector<String, List<String>> resultCollector = 
TypedFunctionService
+      ResultCollector<String, List<String>> resultCollector = 
FunctionServiceCast
           .<Void, String, List<String>>onRegion(getRegion())
           .withFilter(filter)
           .execute(LongRunningFunction.class.getSimpleName(), 
getTimeout().toMillis(),
@@ -302,7 +302,7 @@ public class DistributedRegionFunctionExecutionDUnitTest 
implements Serializable
 
     replicate1.invoke(() -> {
       Throwable thrown = catchThrowable(() -> {
-        TypedFunctionService
+        FunctionServiceCast
             .<Void, String, List<String>>onRegion(getRegion())
             .withFilter(filter)
             .execute(LongRunningFunction.class.getSimpleName(), 1000, 
MILLISECONDS);
@@ -950,7 +950,7 @@ public class DistributedRegionFunctionExecutionDUnitTest 
implements Serializable
     }
 
     client.invoke(() -> {
-      ResultCollector<Boolean, List<Boolean>> resultCollector = 
TypedFunctionService
+      ResultCollector<Boolean, List<Boolean>> resultCollector = 
FunctionServiceCast
           .<Boolean, Boolean, List<Boolean>>onRegion(getRegion())
           .setArguments(true)
           .execute(inlineFunction("Success", true));
@@ -1158,13 +1158,13 @@ public class 
DistributedRegionFunctionExecutionDUnitTest implements Serializable
   }
 
   private void executeNoResultFunction() {
-    TypedFunctionService
+    FunctionServiceCast
         .onRegion(getRegion())
         .execute(new NoResultFunction());
   }
 
   private List<Boolean> executeDistributedRegionFunction() {
-    return TypedFunctionService
+    return FunctionServiceCast
         .<Boolean, Boolean, List<Boolean>>onRegion(getRegion())
         .withFilter(filter)
         .setArguments(false)
@@ -1173,7 +1173,7 @@ public class DistributedRegionFunctionExecutionDUnitTest 
implements Serializable
   }
 
   private void executeThrowsRuntimeExceptionFunction() {
-    TypedFunctionService
+    FunctionServiceCast
         .<Void, Void, Void>onRegion(getRegion())
         .withFilter(filter)
         .execute(new ThrowsRuntimeExceptionFunction());
@@ -1187,7 +1187,7 @@ public class DistributedRegionFunctionExecutionDUnitTest 
implements Serializable
       filter.add("execKey-" + 100 + i);
     }
 
-    ResultCollector<Object, List<Object>> resultCollector = 
TypedFunctionService
+    ResultCollector<Object, List<Object>> resultCollector = FunctionServiceCast
         .<Boolean, Object, List<Object>>onRegion(getRegion())
         .withFilter(filter)
         .setArguments(true)
@@ -1200,7 +1200,7 @@ public class DistributedRegionFunctionExecutionDUnitTest 
implements Serializable
         .as("First element of " + resultCollector.getResult())
         .isInstanceOf(CustomRuntimeException.class);
 
-    resultCollector = TypedFunctionService
+    resultCollector = FunctionServiceCast
         .<Set<String>, Object, List<Object>>onRegion(getRegion())
         .withFilter(filter)
         .setArguments(filter)
@@ -1220,7 +1220,7 @@ public class DistributedRegionFunctionExecutionDUnitTest 
implements Serializable
 
   private void executeNoLastResultFunction() {
     Throwable thrown = catchThrowable(() -> {
-      TypedFunctionService
+      FunctionServiceCast
           .onRegion(getRegion())
           .withFilter(filter)
           .execute(new NoLastResultFunction())
@@ -1234,7 +1234,7 @@ public class DistributedRegionFunctionExecutionDUnitTest 
implements Serializable
   private void executeUnregisteredFunction() {
     FunctionService.unregisterFunction(new 
DistributedRegionFunction().getId());
 
-    TypedFunctionService
+    FunctionServiceCast
         .<Void, Boolean, List<Boolean>>onRegion(getRegion())
         .withFilter(filter)
         .execute(new DistributedRegionFunction())
@@ -1242,7 +1242,7 @@ public class DistributedRegionFunctionExecutionDUnitTest 
implements Serializable
   }
 
   private void executeFunctionFunctionInvocationTargetException() {
-    ResultCollector<Integer, List<Integer>> resultCollector = 
TypedFunctionService
+    ResultCollector<Integer, List<Integer>> resultCollector = 
FunctionServiceCast
         .<Boolean, Integer, List<Integer>>onRegion(getRegion())
         .setArguments(true)
         
.execute(ThrowsFunctionInvocationTargetExceptionFunction.class.getSimpleName());
@@ -1253,7 +1253,7 @@ public class DistributedRegionFunctionExecutionDUnitTest 
implements Serializable
 
   private void executeFunctionFunctionInvocationTargetExceptionWithoutHA() {
     Throwable thrown = catchThrowable(() -> {
-      TypedFunctionService
+      FunctionServiceCast
           .<Boolean, Integer, List<Integer>>onRegion(getRegion())
           .setArguments(true)
           
.execute(ThrowsFunctionInvocationTargetExceptionFunction.class.getSimpleName())
@@ -1268,7 +1268,7 @@ public class DistributedRegionFunctionExecutionDUnitTest 
implements Serializable
   }
 
   private void executeFunctionFunctionInvocationTargetException_ClientServer() 
{
-    ResultCollector<Integer, List<Integer>> resultCollector = 
TypedFunctionService
+    ResultCollector<Integer, List<Integer>> resultCollector = 
FunctionServiceCast
         .<Boolean, Integer, List<Integer>>onRegion(getRegion())
         .setArguments(true)
         
.execute(ThrowsFunctionInvocationTargetExceptionFunction.class.getSimpleName());
@@ -1279,7 +1279,7 @@ public class DistributedRegionFunctionExecutionDUnitTest 
implements Serializable
 
   private void 
executeFunctionFunctionInvocationTargetException_ClientServer_WithoutHA() {
     Throwable thrown = catchThrowable(() -> {
-      TypedFunctionService
+      FunctionServiceCast
           .<Boolean, Integer, List<Integer>>onRegion(getRegion())
           .setArguments(true)
           
.execute(ThrowsFunctionInvocationTargetExceptionFunction.class.getSimpleName())
@@ -1294,7 +1294,7 @@ public class DistributedRegionFunctionExecutionDUnitTest 
implements Serializable
   }
 
   private static <K, V> Region<K, V> getRegion() {
-    return uncheckedCast(REGION.get());
+    return cast(REGION.get());
   }
 
   private static void setRegion(Region<?, ?> region) {
@@ -1327,8 +1327,7 @@ public class DistributedRegionFunctionExecutionDUnitTest 
implements Serializable
     @Override
     public void execute(FunctionContext<Object> context) {
       if (context.getArguments() instanceof Set) {
-        Set<Integer> arguments =
-            uncheckedCast(context.getArguments());
+        Set<Integer> arguments = cast(context.getArguments());
         for (int i = 0; i < arguments.size(); i++) {
           context.getResultSender().sendResult(i);
         }
@@ -1558,4 +1557,26 @@ public class DistributedRegionFunctionExecutionDUnitTest 
implements Serializable
       return -1;
     }
   }
+
+  @SuppressWarnings("unchecked")
+  static class FunctionServiceCast {
+
+    /**
+     * Provide unchecked cast of FunctionService.onRegion.
+     */
+    static <IN, OUT, AGG> Execution<IN, OUT, AGG> onRegion(Region<?, ?> 
region) {
+      return FunctionService.onRegion(region);
+    }
+  }
+
+  @SuppressWarnings({"unchecked", "unused"})
+  static class UncheckedUtils {
+
+    /**
+     * Provide unchecked cast of specified Object.
+     */
+    static <T> T cast(Object object) {
+      return (T) object;
+    }
+  }
 }
diff --git 
a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/partitioned/fixed/FixedPartitioningWithColocationAndPersistenceDUnitTest.java
 
b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/partitioned/fixed/FixedPartitioningWithColocationAndPersistenceDUnitTest.java
index 99db19a..ea7c834 100644
--- 
a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/partitioned/fixed/FixedPartitioningWithColocationAndPersistenceDUnitTest.java
+++ 
b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/partitioned/fixed/FixedPartitioningWithColocationAndPersistenceDUnitTest.java
@@ -36,10 +36,10 @@ import static 
org.apache.geode.internal.cache.partitioned.fixed.FixedPartitionin
 import static 
org.apache.geode.internal.cache.partitioned.fixed.FixedPartitioningWithColocationAndPersistenceDUnitTest.Quarter.Q2;
 import static 
org.apache.geode.internal.cache.partitioned.fixed.FixedPartitioningWithColocationAndPersistenceDUnitTest.Quarter.Q3;
 import static 
org.apache.geode.internal.cache.partitioned.fixed.FixedPartitioningWithColocationAndPersistenceDUnitTest.Quarter.Q4;
+import static org.apache.geode.internal.cache.util.UncheckedUtils.cast;
 import static org.apache.geode.test.awaitility.GeodeAwaitility.await;
 import static org.apache.geode.test.dunit.VM.getVM;
 import static org.apache.geode.test.dunit.VM.getVMId;
-import static org.apache.geode.util.internal.UncheckedUtils.uncheckedCast;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.catchThrowable;
 import static org.mockito.Mockito.mock;
@@ -1502,9 +1502,9 @@ public class 
FixedPartitioningWithColocationAndPersistenceDUnitTest implements S
     PartitionedRegionDataStore dataStore = partitionedRegion.getDataStore();
 
     if (dataStore != null) {
-      return uncheckedCast(new LocalDataSet(partitionedRegion, 
dataStore.getAllLocalBucketIds()));
+      return cast(new LocalDataSet(partitionedRegion, 
dataStore.getAllLocalBucketIds()));
     }
-    return uncheckedCast(new LocalDataSet(partitionedRegion, emptySet()));
+    return cast(new LocalDataSet(partitionedRegion, emptySet()));
   }
 
   private void validateQuartersData() throws ParseException {
@@ -1555,20 +1555,20 @@ public class 
FixedPartitioningWithColocationAndPersistenceDUnitTest implements S
       InternalDistributedMember idmForShipment = shipments.getBucketPrimary(i);
 
       // take all the keys from the shipment for each bucket
-      Set<CustomerId> customerKey = uncheckedCast(customers.getBucketKeys(i));
+      Set<CustomerId> customerKey = cast(customers.getBucketKeys(i));
       assertThat(customerKey).isNotNull();
 
       for (CustomerId customerId : customerKey) {
         assertThat(customers.get(customerId)).isNotNull();
 
-        Set<OrderId> orderKey = uncheckedCast(orders.getBucketKeys(i));
+        Set<OrderId> orderKey = cast(orders.getBucketKeys(i));
         for (OrderId orderId : orderKey) {
           assertThat(orders.get(orderId)).isNotNull();
           if (orderId.getCustomerId().equals(customerId)) {
             assertThat(idmForOrder).isEqualTo(idmForCustomer);
           }
 
-          Set<ShipmentId> shipmentKey = 
uncheckedCast(shipments.getBucketKeys(i));
+          Set<ShipmentId> shipmentKey = cast(shipments.getBucketKeys(i));
           for (ShipmentId shipmentId : shipmentKey) {
             assertThat(shipments.get(shipmentId)).isNotNull();
             if (shipmentId.getOrderId().equals(orderId)) {
diff --git 
a/geode-core/src/integrationTest/java/org/apache/geode/internal/cache/execute/FunctionExecutionOnLonerRegressionTest.java
 
b/geode-core/src/integrationTest/java/org/apache/geode/internal/cache/execute/FunctionExecutionOnLonerRegressionTest.java
index d0c4cbc..08b75cf 100644
--- 
a/geode-core/src/integrationTest/java/org/apache/geode/internal/cache/execute/FunctionExecutionOnLonerRegressionTest.java
+++ 
b/geode-core/src/integrationTest/java/org/apache/geode/internal/cache/execute/FunctionExecutionOnLonerRegressionTest.java
@@ -19,7 +19,7 @@ import static org.apache.geode.cache.RegionShortcut.REPLICATE;
 import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
 import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
 import static 
org.apache.geode.distributed.ConfigurationProperties.SERIALIZABLE_OBJECT_FILTER;
-import static org.apache.geode.util.internal.UncheckedUtils.uncheckedCast;
+import static 
org.apache.geode.internal.cache.execute.FunctionExecutionOnLonerRegressionTest.UncheckedUtils.cast;
 import static org.assertj.core.api.Assertions.assertThat;
 
 import java.util.Collection;
@@ -35,14 +35,15 @@ import org.junit.experimental.categories.Category;
 
 import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.Region;
+import org.apache.geode.cache.execute.Execution;
 import org.apache.geode.cache.execute.FunctionContext;
+import org.apache.geode.cache.execute.FunctionService;
 import org.apache.geode.cache.execute.RegionFunctionContext;
 import org.apache.geode.cache.execute.ResultCollector;
 import org.apache.geode.cache.partition.PartitionRegionHelper;
 import org.apache.geode.distributed.internal.DistributionManager;
 import org.apache.geode.distributed.internal.LonerDistributionManager;
 import org.apache.geode.internal.cache.InternalCache;
-import org.apache.geode.internal.cache.execute.util.TypedFunctionService;
 import org.apache.geode.test.junit.categories.FunctionServiceTest;
 
 /**
@@ -87,7 +88,7 @@ public class FunctionExecutionOnLonerRegressionTest {
 
     populateRegion(region);
 
-    ResultCollector<Collection<String>, Collection<String>> resultCollector = 
TypedFunctionService
+    ResultCollector<Collection<String>, Collection<String>> resultCollector = 
FunctionServiceCast
         .<Void, Collection<String>, Collection<String>>onRegion(region)
         .withFilter(keysForGet)
         .execute(new TestFunction(DataSetSupplier.PARTITIONED));
@@ -104,7 +105,7 @@ public class FunctionExecutionOnLonerRegressionTest {
 
     populateRegion(region);
 
-    ResultCollector<Collection<String>, Collection<String>> resultCollector = 
TypedFunctionService
+    ResultCollector<Collection<String>, Collection<String>> resultCollector = 
FunctionServiceCast
         .<Void, Collection<String>, Collection<String>>onRegion(region)
         .withFilter(keysForGet)
         .execute(new TestFunction(DataSetSupplier.REPLICATE));
@@ -166,7 +167,7 @@ public class FunctionExecutionOnLonerRegressionTest {
     @Override
     public void execute(FunctionContext<String> context) {
       RegionFunctionContext regionFunctionContext = (RegionFunctionContext) 
context;
-      Set<String> keys = uncheckedCast(regionFunctionContext.getFilter());
+      Set<String> keys = cast(regionFunctionContext.getFilter());
       String lastKey = keys.iterator().next();
       keys.remove(lastKey);
 
@@ -184,4 +185,20 @@ public class FunctionExecutionOnLonerRegressionTest {
       return getClass().getName();
     }
   }
+
+  @SuppressWarnings({"unchecked", "WeakerAccess"})
+  private static class FunctionServiceCast {
+
+    static <IN, OUT, AGG> Execution<IN, OUT, AGG> onRegion(Region<?, ?> 
region) {
+      return FunctionService.onRegion(region);
+    }
+  }
+
+  @SuppressWarnings({"unchecked", "unused"})
+  static class UncheckedUtils {
+
+    static <T> T cast(Object object) {
+      return (T) object;
+    }
+  }
 }
diff --git 
a/geode-core/src/main/java/org/apache/geode/cache/client/internal/ClientMetadataService.java
 
b/geode-core/src/main/java/org/apache/geode/cache/client/internal/ClientMetadataService.java
index 8b89bb8..0aaa9df 100755
--- 
a/geode-core/src/main/java/org/apache/geode/cache/client/internal/ClientMetadataService.java
+++ 
b/geode-core/src/main/java/org/apache/geode/cache/client/internal/ClientMetadataService.java
@@ -14,7 +14,7 @@
  */
 package org.apache.geode.cache.client.internal;
 
-import static org.apache.geode.util.internal.UncheckedUtils.uncheckedCast;
+import static org.apache.geode.internal.cache.util.UncheckedUtils.cast;
 
 import java.util.ArrayList;
 import java.util.Collection;
@@ -230,7 +230,7 @@ public class ClientMetadataService {
 
     for (Map.Entry entry : serverToBuckets.entrySet()) {
       ServerLocation server = (ServerLocation) entry.getKey();
-      Set<Integer> buckets = uncheckedCast(entry.getValue());
+      Set<Integer> buckets = cast(entry.getValue());
       for (Integer bucket : buckets) {
         // use LinkedHashSet to maintain the order of keys
         // the keys will be iterated several times
diff --git 
a/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
 
b/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
index 2cd1f3c..2f6b0b4 100755
--- 
a/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
+++ 
b/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
@@ -33,6 +33,10 @@ import static 
org.apache.geode.distributed.internal.ClusterDistributionManager.L
 import static 
org.apache.geode.distributed.internal.DistributionConfig.DEFAULT_DURABLE_CLIENT_ID;
 import static 
org.apache.geode.distributed.internal.InternalDistributedSystem.getAnyInstance;
 import static 
org.apache.geode.internal.cache.ColocationHelper.getColocatedChildRegions;
+import static 
org.apache.geode.internal.cache.GemFireCacheImpl.UncheckedUtils.asDistributedMemberSet;
+import static 
org.apache.geode.internal.cache.GemFireCacheImpl.UncheckedUtils.createMapArray;
+import static 
org.apache.geode.internal.cache.GemFireCacheImpl.UncheckedUtils.uncheckedCast;
+import static 
org.apache.geode.internal.cache.GemFireCacheImpl.UncheckedUtils.uncheckedRegionAttributes;
 import static 
org.apache.geode.internal.cache.LocalRegion.setThreadInitLevelRequirement;
 import static 
org.apache.geode.internal.cache.PartitionedRegion.DISK_STORE_FLUSHED;
 import static 
org.apache.geode.internal.cache.PartitionedRegion.OFFLINE_EQUAL_PERSISTED;
@@ -40,11 +44,11 @@ import static 
org.apache.geode.internal.cache.PartitionedRegion.PRIMARY_BUCKETS_
 import static 
org.apache.geode.internal.cache.PartitionedRegionHelper.PARTITION_LOCK_SERVICE_NAME;
 import static 
org.apache.geode.internal.cache.control.InternalResourceManager.ResourceType.HEAP_MEMORY;
 import static 
org.apache.geode.internal.cache.control.InternalResourceManager.ResourceType.OFFHEAP_MEMORY;
+import static org.apache.geode.internal.cache.util.UncheckedUtils.cast;
 import static 
org.apache.geode.internal.logging.CoreLoggingExecutors.newThreadPoolWithFixedFeed;
 import static 
org.apache.geode.internal.tcp.ConnectionTable.threadWantsSharedResources;
 import static 
org.apache.geode.logging.internal.executors.LoggingExecutors.newFixedThreadPool;
 import static org.apache.geode.util.internal.GeodeGlossary.GEMFIRE_PREFIX;
-import static org.apache.geode.util.internal.UncheckedUtils.uncheckedCast;
 
 import java.io.BufferedReader;
 import java.io.ByteArrayInputStream;
@@ -1808,7 +1812,7 @@ public class GemFireCacheImpl implements InternalCache, 
InternalClientCache, Has
             && partitionedRegion.getDataPolicy() == 
DataPolicy.PERSISTENT_PARTITION) {
           int numBuckets = partitionedRegion.getTotalNumberOfBuckets();
           Map<InternalDistributedMember, PersistentMemberID>[] bucketMaps =
-              uncheckedCast(new Map[numBuckets]);
+              createMapArray(numBuckets);
           PartitionedRegionDataStore dataStore = 
partitionedRegion.getDataStore();
 
           // lock all the primary buckets
@@ -2662,18 +2666,18 @@ public class GemFireCacheImpl implements InternalCache, 
InternalClientCache, Has
 
   @Override
   public Set<DistributedMember> getAdminMembers() {
-    return uncheckedCast(dm.getAdminMemberSet());
+    return asDistributedMemberSet(dm.getAdminMemberSet());
   }
 
   @Override
   public Set<DistributedMember> getMembers(Region region) {
     if (region instanceof DistributedRegion) {
       DistributedRegion distributedRegion = (DistributedRegion) region;
-      return 
uncheckedCast(distributedRegion.getDistributionAdvisor().adviseCacheOp());
+      return 
asDistributedMemberSet(distributedRegion.getDistributionAdvisor().adviseCacheOp());
     }
     if (region instanceof PartitionedRegion) {
       PartitionedRegion partitionedRegion = (PartitionedRegion) region;
-      return 
uncheckedCast(partitionedRegion.getRegionAdvisor().adviseAllPRNodes());
+      return 
asDistributedMemberSet(partitionedRegion.getRegionAdvisor().adviseAllPRNodes());
     }
     return emptySet();
   }
@@ -3059,14 +3063,15 @@ public class GemFireCacheImpl implements InternalCache, 
InternalClientCache, Has
       system.handleResourceEvent(ResourceEvent.REGION_CREATE, region);
     }
 
-    return uncheckedCast(region);
+    return cast(region);
   }
 
   @Override
   public <K, V> RegionAttributes<K, V> invokeRegionBefore(InternalRegion 
parent, String name,
       RegionAttributes<K, V> attrs, InternalRegionArguments 
internalRegionArgs) {
     for (RegionListener listener : regionListeners) {
-      attrs = uncheckedCast(listener.beforeCreate(parent, name, attrs, 
internalRegionArgs));
+      attrs =
+          uncheckedRegionAttributes(listener.beforeCreate(parent, name, attrs, 
internalRegionArgs));
     }
     return attrs;
   }
@@ -3182,7 +3187,7 @@ public class GemFireCacheImpl implements InternalCache, 
InternalClientCache, Has
 
   @Override
   public <K, V> Region<K, V> getRegionByPath(String path) {
-    return uncheckedCast(getInternalRegionByPath(path));
+    return cast(getInternalRegionByPath(path));
   }
 
   @Override
@@ -3239,7 +3244,7 @@ public class GemFireCacheImpl implements InternalCache, 
InternalClientCache, Has
         stopper.checkCancelInProgress(null);
         return null;
       }
-      return uncheckedCast(result);
+      return cast(result);
     }
 
     String[] pathParts = parsePath(path);
@@ -3263,7 +3268,7 @@ public class GemFireCacheImpl implements InternalCache, 
InternalClientCache, Has
       logger.debug("GemFireCache.getRegion, calling getSubregion on 
rootRegion({}): {}",
           pathParts[0], pathParts[1]);
     }
-    return uncheckedCast(rootRegion.getSubregion(pathParts[1], 
returnDestroyedRegion));
+    return cast(rootRegion.getSubregion(pathParts[1], returnDestroyedRegion));
   }
 
   @Override
@@ -4053,7 +4058,7 @@ public class GemFireCacheImpl implements InternalCache, 
InternalClientCache, Has
 
   @Override
   public <K, V> RegionAttributes<K, V> getRegionAttributes(String id) {
-    return uncheckedCast(namedRegionAttributes.get(id));
+    return GemFireCacheImpl.UncheckedUtils.<K, 
V>uncheckedCast(namedRegionAttributes).get(id);
   }
 
   @Override
@@ -5171,6 +5176,28 @@ public class GemFireCacheImpl implements InternalCache, 
InternalClientCache, Has
     }
   }
 
+  @SuppressWarnings("unchecked")
+  static class UncheckedUtils {
+
+    static Map<InternalDistributedMember, PersistentMemberID>[] 
createMapArray(int size) {
+      return new Map[size];
+    }
+
+    static Set<DistributedMember> asDistributedMemberSet(
+        Set<InternalDistributedMember> internalDistributedMembers) {
+      return (Set) internalDistributedMembers;
+    }
+
+    static <K, V> RegionAttributes<K, V> 
uncheckedRegionAttributes(RegionAttributes region) {
+      return region;
+    }
+
+    static <K, V> Map<String, RegionAttributes<K, V>> uncheckedCast(
+        Map<String, RegionAttributes<?, ?>> namedRegionAttributes) {
+      return (Map) namedRegionAttributes;
+    }
+  }
+
   @FunctionalInterface
   @VisibleForTesting
   interface TXManagerImplFactory {
diff --git 
a/geode-core/src/main/java/org/apache/geode/internal/cache/InternalCacheForClientAccess.java
 
b/geode-core/src/main/java/org/apache/geode/internal/cache/InternalCacheForClientAccess.java
index dbbb98b..10635fe 100644
--- 
a/geode-core/src/main/java/org/apache/geode/internal/cache/InternalCacheForClientAccess.java
+++ 
b/geode-core/src/main/java/org/apache/geode/internal/cache/InternalCacheForClientAccess.java
@@ -16,7 +16,7 @@
  */
 package org.apache.geode.internal.cache;
 
-import static org.apache.geode.util.internal.UncheckedUtils.uncheckedCast;
+import static org.apache.geode.internal.cache.util.UncheckedUtils.cast;
 
 import java.io.File;
 import java.io.IOException;
@@ -162,7 +162,7 @@ public class InternalCacheForClientAccess implements 
InternalCache {
   public <K, V> Region<K, V> getRegion(String path, boolean 
returnDestroyedRegion) {
     Region result = delegate.getRegion(path, returnDestroyedRegion);
     checkForInternalRegion(result);
-    return uncheckedCast(result);
+    return cast(result);
   }
 
   @Override
@@ -176,7 +176,7 @@ public class InternalCacheForClientAccess implements 
InternalCache {
   public <K, V> Region<K, V> getRegionByPath(String path) {
     InternalRegion result = delegate.getInternalRegionByPath(path);
     checkForInternalRegion(result);
-    return uncheckedCast(result);
+    return cast(result);
   }
 
   @Override
diff --git 
a/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java 
b/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java
index 098115b..849187b 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java
@@ -17,9 +17,9 @@ package org.apache.geode.internal.cache;
 import static 
org.apache.geode.internal.cache.LocalRegion.InitializationLevel.AFTER_INITIAL_IMAGE;
 import static 
org.apache.geode.internal.cache.LocalRegion.InitializationLevel.ANY_INIT;
 import static 
org.apache.geode.internal.cache.LocalRegion.InitializationLevel.BEFORE_INITIAL_IMAGE;
+import static org.apache.geode.internal.cache.util.UncheckedUtils.cast;
 import static org.apache.geode.internal.lang.SystemUtils.getLineSeparator;
 import static 
org.apache.geode.internal.offheap.annotations.OffHeapIdentifier.ENTRY_EVENT_NEW_VALUE;
-import static org.apache.geode.util.internal.UncheckedUtils.uncheckedCast;
 
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
@@ -8943,10 +8943,7 @@ public class LocalRegion extends AbstractRegion 
implements LoaderHelperFactory,
         txState.getRealDeal(null, this);
       }
       try {
-        proxyResult = getServerProxy().putAll(
-            uncheckedCast(map),
-            eventId,
-            !event.isGenerateCallbacks(),
+        proxyResult = getServerProxy().putAll(cast(map), eventId, 
!event.isGenerateCallbacks(),
             event.getCallbackArgument());
         if (isDebugEnabled) {
           logger.debug("PutAll received response from server: {}", 
proxyResult);
diff --git 
a/geode-core/src/main/java/org/apache/geode/internal/cache/execute/util/TypedFunctionService.java
 
b/geode-core/src/main/java/org/apache/geode/internal/cache/execute/util/TypedFunctionService.java
deleted file mode 100644
index 3f21439..0000000
--- 
a/geode-core/src/main/java/org/apache/geode/internal/cache/execute/util/TypedFunctionService.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.geode.internal.cache.execute.util;
-
-import org.apache.geode.cache.Region;
-import org.apache.geode.cache.execute.Execution;
-import org.apache.geode.cache.execute.FunctionService;
-
-/**
- * Utilities for casting and working around raw types in the {@link 
FunctionService} API.
- */
-@SuppressWarnings({"unchecked", "unused"})
-public class TypedFunctionService {
-
-  protected TypedFunctionService() {
-    // do not instantiate
-  }
-
-  /**
-   * Adds parameterized type support to {@link 
FunctionService#onRegion(Region)}.
-   */
-  public static <IN, OUT, AGG> Execution<IN, OUT, AGG> onRegion(Region<?, ?> 
region) {
-    return FunctionService.onRegion(region);
-  }
-}
diff --git 
a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/CacheClientProxyFactory.java
 
b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/CacheClientProxyFactory.java
index ae26aa7..a3def49 100644
--- 
a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/CacheClientProxyFactory.java
+++ 
b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/CacheClientProxyFactory.java
@@ -14,7 +14,7 @@
  */
 package org.apache.geode.internal.cache.tier.sockets;
 
-import static org.apache.geode.util.internal.UncheckedUtils.uncheckedCast;
+import static org.apache.geode.internal.cache.util.UncheckedUtils.cast;
 
 import java.lang.reflect.InvocationTargetException;
 import java.net.Socket;
@@ -55,7 +55,7 @@ public class CacheClientProxyFactory {
     }
     try {
       Class<InternalCacheClientProxyFactory> proxyClass =
-          uncheckedCast(ClassPathLoader.getLatest().forName(proxyClassName));
+          cast(ClassPathLoader.getLatest().forName(proxyClassName));
       return proxyClass.getConstructor().newInstance();
     } catch (ClassNotFoundException | NoSuchMethodException | 
InstantiationException
         | IllegalAccessException | InvocationTargetException e) {
diff --git 
a/geode-common/src/main/java/org/apache/geode/util/internal/UncheckedUtils.java 
b/geode-core/src/main/java/org/apache/geode/internal/cache/util/UncheckedUtils.java
similarity index 68%
rename from 
geode-common/src/main/java/org/apache/geode/util/internal/UncheckedUtils.java
rename to 
geode-core/src/main/java/org/apache/geode/internal/cache/util/UncheckedUtils.java
index 61dbd8d..c03e990 100644
--- 
a/geode-common/src/main/java/org/apache/geode/util/internal/UncheckedUtils.java
+++ 
b/geode-core/src/main/java/org/apache/geode/internal/cache/util/UncheckedUtils.java
@@ -12,23 +12,18 @@
  * or implied. See the License for the specific language governing permissions 
and limitations under
  * the License.
  */
-package org.apache.geode.util.internal;
+package org.apache.geode.internal.cache.util;
+
+import org.apache.geode.cache.execute.Execution;
 
-/**
- * Utilities for casting and working with unchecked raw types.
- */
 @SuppressWarnings({"unchecked", "unused"})
 public class UncheckedUtils {
 
-  protected UncheckedUtils() {
-    // do not instantiate
+  public static <T> T cast(Object object) {
+    return (T) object;
   }
 
-  /**
-   * Casts an instance of a raw type to a parameterized type. Preference 
should be given to
-   * converting all code from using raw types to using parameterized types 
when possible.
-   */
-  public static <T> T uncheckedCast(Object object) {
-    return (T) object;
+  public static <IN, OUT, AGG> Execution<IN, OUT, AGG> cast(Execution 
execution) {
+    return execution;
   }
 }
diff --git 
a/geode-core/src/test/java/org/apache/geode/alerting/internal/ClusterAlertMessagingTest.java
 
b/geode-core/src/test/java/org/apache/geode/alerting/internal/ClusterAlertMessagingTest.java
index eadf54b..f7bc8d8 100644
--- 
a/geode-core/src/test/java/org/apache/geode/alerting/internal/ClusterAlertMessagingTest.java
+++ 
b/geode-core/src/test/java/org/apache/geode/alerting/internal/ClusterAlertMessagingTest.java
@@ -14,7 +14,7 @@
  */
 package org.apache.geode.alerting.internal;
 
-import static org.apache.geode.util.internal.UncheckedUtils.uncheckedCast;
+import static org.apache.geode.internal.cache.util.UncheckedUtils.cast;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.catchThrowable;
 import static org.mockito.ArgumentMatchers.anyLong;
@@ -141,7 +141,7 @@ public class ClusterAlertMessagingTest {
   public void sendAlertLogsWarning_ifAlertingIOExceptionIsCaught() {
     ExecutorService executor = currentThreadExecutorService();
     ClusterDistributionManager distributionManager = 
mock(ClusterDistributionManager.class);
-    Consumer<AlertingIOException> alertingIOExceptionLogger = 
uncheckedCast(mock(Consumer.class));
+    Consumer<AlertingIOException> alertingIOExceptionLogger = 
cast(mock(Consumer.class));
     ClusterAlertMessaging clusterAlertMessaging =
         spyClusterAlertMessaging(distributionManager, executor, 
alertingIOExceptionLogger);
     doThrow(new AlertingIOException(new IOException("Cannot form connection to 
alert listener")))
@@ -162,7 +162,7 @@ public class ClusterAlertMessagingTest {
   public void sendAlertLogsWarningOnce_ifAlertingIOExceptionIsCaught() {
     ExecutorService executor = currentThreadExecutorService();
     ClusterDistributionManager distributionManager = 
mock(ClusterDistributionManager.class);
-    Consumer<AlertingIOException> alertingIOExceptionLogger = 
uncheckedCast(mock(Consumer.class));
+    Consumer<AlertingIOException> alertingIOExceptionLogger = 
cast(mock(Consumer.class));
     ClusterAlertMessaging clusterAlertMessaging =
         spyClusterAlertMessaging(distributionManager, executor, 
alertingIOExceptionLogger);
     doThrow(new AlertingIOException(new IOException("Cannot form connection to 
alert listener")))
diff --git 
a/geode-core/src/test/java/org/apache/geode/internal/tcp/TCPConduitTest.java 
b/geode-core/src/test/java/org/apache/geode/internal/tcp/TCPConduitTest.java
index c0bf0a5..0c30ce2 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/tcp/TCPConduitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/tcp/TCPConduitTest.java
@@ -16,7 +16,7 @@
  */
 package org.apache.geode.internal.tcp;
 
-import static org.apache.geode.util.internal.UncheckedUtils.uncheckedCast;
+import static org.apache.geode.internal.cache.util.UncheckedUtils.cast;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.catchThrowable;
 import static org.mockito.Mockito.anyBoolean;
@@ -62,7 +62,7 @@ public class TCPConduitTest {
 
   @Before
   public void setUp() throws Exception {
-    membership = uncheckedCast(mock(Membership.class));
+    membership = cast(mock(Membership.class));
     directChannel = mock(DirectChannel.class);
     connectionTable = mock(ConnectionTable.class);
     socketCreator = new SocketCreator(new SSLConfig.Builder().build());

Reply via email to