You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by bs...@apache.org on 2020/03/05 17:06:52 UTC

[geode] branch feature/GEODE-7808_testing_wip created (now 61949a9)

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

bschuchardt pushed a change to branch feature/GEODE-7808_testing_wip
in repository https://gitbox.apache.org/repos/asf/geode.git.


      at 61949a9  GEODE-7808: standardize on use of HostAndPort for connection formation

This branch includes the following new commits:

     new 61949a9  GEODE-7808: standardize on use of HostAndPort for connection formation

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[geode] 01/01: GEODE-7808: standardize on use of HostAndPort for connection formation

Posted by bs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

bschuchardt pushed a commit to branch feature/GEODE-7808_testing_wip
in repository https://gitbox.apache.org/repos/asf/geode.git

commit 61949a99feeb6553cfd915c6470da2007589324b
Author: Bruce Schuchardt <bs...@pivotal.io>
AuthorDate: Thu Mar 5 08:49:12 2020 -0800

    GEODE-7808: standardize on use of HostAndPort for connection formation
    
    Adding two tests that limit the use of InetAddress and of
    InetSocketAddress.getAddress().  Ideally we could whittle down the
    list of exceptions currently being "sanctioned" by the InetAddress test.
    
    I tried using the PMD tool that's already built into our gradle builds
    to perform these restrictions but it fails with parsing errors.  Instead
    I turned to the "decode" package that's used by
    AnalyzeSerializablesTestBase and refactored that into a Rule that can be
    used by any test to load its module's class files in partially
    decompiled form.  I added a couple of query methods to CompiledClass to
    search for uses of InetAddress and InetSocketAddress.getAddress().
    
    The InetAddress test turned up 74 violations.  I removed some of these
    by getting rid of unnecessary code or moving it to LocalHostUtil and
    categorized the other violations and moved them into a "sanctioned" list
    that we should work on making as small as possible.
---
 .../apache/geode/metrics/CacheCommonTagsTest.java  |  2 +-
 .../apache/geode/internal/inet/LocalHostUtil.java  | 13 ++++
 .../SimpleStatSamplerIntegrationTest.java          |  2 +-
 .../client/internal/AutoConnectionSourceImpl.java  | 12 ++--
 .../java/org/apache/geode/distributed/Locator.java |  2 +-
 .../internal/DistributionConfigImpl.java           |  2 +-
 .../distributed/internal/DistributionManager.java  |  4 +-
 .../internal/LonerDistributionManager.java         | 14 +---
 .../membership/InternalDistributedMember.java      |  2 +-
 .../apache/geode/internal/VersionDescription.java  |  2 +-
 .../geode/internal/cache/GemFireCacheImpl.java     |  4 +-
 .../apache/geode/internal/net/SocketCreator.java   |  6 ++
 .../geode/internal/statistics/HostStatSampler.java |  2 +-
 .../internal/statistics/OsStatisticsProvider.java  |  7 +-
 .../internal/statistics/StatArchiveWriter.java     |  2 +-
 .../geode/management/internal/ManagementAgent.java |  2 +-
 .../internal/beans/MemberMBeanBridge.java          |  2 +-
 .../AnalyzeSerializablesJUnitTestBase.java         | 77 +++++-----------------
 .../geode/codeAnalysis/decode/CompiledClass.java   | 33 +++++++++-
 .../geode/codeAnalysis/decode/cp/CpFieldref.java   |  8 +++
 .../geode/codeAnalysis/decode/cp/CpMethodref.java  |  1 +
 .../codeAnalysis/decode/cp/CpNameAndType.java      | 10 +++
 .../locator/GMSLocatorRecoveryIntegrationTest.java |  2 +-
 .../gms/locator/MembershipLocatorImpl.java         |  2 +-
 .../tcpserver/TcpServerGossipVersionDUnitTest.java |  2 +-
 .../WANHostNameVerificationDistributedTest.java    |  6 +-
 .../internal/cache/wan/GatewayReceiverImpl.java    |  2 +-
 .../cache/wan/GatewayReceiverImplTest.java         |  2 +-
 28 files changed, 120 insertions(+), 105 deletions(-)

diff --git a/geode-assembly/src/acceptanceTest/java/org/apache/geode/metrics/CacheCommonTagsTest.java b/geode-assembly/src/acceptanceTest/java/org/apache/geode/metrics/CacheCommonTagsTest.java
index 58a1cfd..15176dd 100644
--- a/geode-assembly/src/acceptanceTest/java/org/apache/geode/metrics/CacheCommonTagsTest.java
+++ b/geode-assembly/src/acceptanceTest/java/org/apache/geode/metrics/CacheCommonTagsTest.java
@@ -56,7 +56,7 @@ public class CacheCommonTagsTest {
 
       assertThat(meter.getId().getTags())
           .as("Tags for meter with name " + meterId.getName())
-          .contains(Tag.of("host", LocalHostUtil.getLocalHost().getHostName()));
+          .contains(Tag.of("host", LocalHostUtil.getLocalHostName()));
     }
   }
 
diff --git a/geode-common/src/main/java/org/apache/geode/internal/inet/LocalHostUtil.java b/geode-common/src/main/java/org/apache/geode/internal/inet/LocalHostUtil.java
index f904c55..6db37c9 100644
--- a/geode-common/src/main/java/org/apache/geode/internal/inet/LocalHostUtil.java
+++ b/geode-common/src/main/java/org/apache/geode/internal/inet/LocalHostUtil.java
@@ -283,4 +283,17 @@ public class LocalHostUtil {
       throw new IllegalArgumentException(e.getMessage());
     }
   }
+
+  public static String getLocalHostName() throws UnknownHostException {
+    return getLocalHost().getHostName();
+  }
+
+  public static String getLocalHostString() throws UnknownHostException {
+    return getLocalHost().toString();
+  }
+
+  public static String getCanonicalLocalHostName() throws UnknownHostException {
+    return getLocalHost().getCanonicalHostName();
+
+  }
 }
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/internal/statistics/SimpleStatSamplerIntegrationTest.java b/geode-core/src/integrationTest/java/org/apache/geode/internal/statistics/SimpleStatSamplerIntegrationTest.java
index ecfb5f3..33d94ef 100755
--- a/geode-core/src/integrationTest/java/org/apache/geode/internal/statistics/SimpleStatSamplerIntegrationTest.java
+++ b/geode-core/src/integrationTest/java/org/apache/geode/internal/statistics/SimpleStatSamplerIntegrationTest.java
@@ -99,7 +99,7 @@ public class SimpleStatSamplerIntegrationTest extends StatSamplerTestCase {
     assertTrue(statsCount > 0);
 
     assertTrue(statSampler.getSystemStartTime() <= System.currentTimeMillis());
-    assertEquals(LocalHostUtil.getLocalHost().getHostName(),
+    assertEquals(LocalHostUtil.getLocalHostName(),
         statSampler.getSystemDirectoryPath());
 
     VMStatsContract vmStats = statSampler.getVMStats();
diff --git a/geode-core/src/main/java/org/apache/geode/cache/client/internal/AutoConnectionSourceImpl.java b/geode-core/src/main/java/org/apache/geode/cache/client/internal/AutoConnectionSourceImpl.java
index 94336f3..cbc03f8 100644
--- a/geode-core/src/main/java/org/apache/geode/cache/client/internal/AutoConnectionSourceImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/cache/client/internal/AutoConnectionSourceImpl.java
@@ -73,19 +73,23 @@ public class AutoConnectionSourceImpl implements ConnectionSource {
   @Immutable
   private static final LocatorListRequest LOCATOR_LIST_REQUEST = new LocatorListRequest();
 
+  /**
+   * A Comparator used to sort a list of locator addresses. This should not be
+   * used in other ways as it can return zero when two addresses aren't actually equal.
+   */
   @Immutable
   private static final Comparator<HostAndPort> SOCKET_ADDRESS_COMPARATOR =
       (address, otherAddress) -> {
         InetSocketAddress inetSocketAddress = address.getSocketInetAddress();
         InetSocketAddress otherInetSocketAddress = otherAddress.getSocketInetAddress();
         // shouldn't happen, but if it does we'll say they're the same.
-        if (inetSocketAddress.getAddress() == null
-            || otherInetSocketAddress.getAddress() == null) {
+        if (inetSocketAddress.getHostString() == null
+            || otherInetSocketAddress.getHostString() == null) {
           return 0;
         }
 
-        int result = inetSocketAddress.getAddress().getCanonicalHostName()
-            .compareTo(otherInetSocketAddress.getAddress().getCanonicalHostName());
+        int result = inetSocketAddress.getHostString()
+            .compareTo(otherInetSocketAddress.getHostString());
         if (result != 0) {
           return result;
         } else {
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/Locator.java b/geode-core/src/main/java/org/apache/geode/distributed/Locator.java
index 3d5df2a..e4b2c98 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/Locator.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/Locator.java
@@ -385,7 +385,7 @@ public abstract class Locator {
     Object ba = this.bindAddress;
     if (ba == null) {
       try {
-        ba = LocalHostUtil.getLocalHost().getHostName();
+        ba = LocalHostUtil.getLocalHostName();
       } catch (java.net.UnknownHostException uh) {
       }
     }
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionConfigImpl.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionConfigImpl.java
index e039a2a..047e6e0 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionConfigImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionConfigImpl.java
@@ -1776,7 +1776,7 @@ public class DistributionConfigImpl extends AbstractDistributionConfig implement
         return bindAddress + "[" + startLocatorPort + "]";
       }
       try {
-        return LocalHostUtil.getLocalHost().getHostName() + "[" + startLocatorPort
+        return LocalHostUtil.getLocalHostName() + "[" + startLocatorPort
             + "]";
       } catch (UnknownHostException ignore) {
         // punt and use this.startLocator instead
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionManager.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionManager.java
index 1db7aad..0db1014 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionManager.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionManager.java
@@ -336,7 +336,9 @@ public interface DistributionManager extends ReplySender {
    */
   boolean areOnEquivalentHost(InternalDistributedMember member1, InternalDistributedMember member2);
 
-  Set<InetAddress> getEquivalents(InetAddress in);
+  default Set<InetAddress> getEquivalents(InetAddress in) {
+    throw new UnsupportedOperationException();
+  }
 
   Set<DistributedMember> getGroupMembers(String group);
 
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/LonerDistributionManager.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/LonerDistributionManager.java
index 6f4430a..8af9e3c 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/LonerDistributionManager.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/LonerDistributionManager.java
@@ -14,12 +14,10 @@
  */
 package org.apache.geode.distributed.internal;
 
-import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -49,7 +47,6 @@ import org.apache.geode.distributed.internal.membership.InternalDistributedMembe
 import org.apache.geode.distributed.internal.membership.api.MemberDataBuilder;
 import org.apache.geode.i18n.LogWriterI18n;
 import org.apache.geode.internal.cache.InternalCache;
-import org.apache.geode.internal.inet.LocalHostUtil;
 import org.apache.geode.internal.logging.InternalLogWriter;
 import org.apache.geode.internal.monitoring.ThreadsMonitoring;
 import org.apache.geode.internal.monitoring.ThreadsMonitoringImpl;
@@ -1205,9 +1202,7 @@ public class LonerDistributionManager implements DistributionManager {
 
       String name = this.system.getName();
 
-      InetAddress hostAddr = LocalHostUtil.getLocalHost();
-      host = SocketCreator.use_client_host_name ? hostAddr.getCanonicalHostName()
-          : hostAddr.getHostAddress();
+      host = SocketCreator.getClientHostName();
       DistributionConfig config = system.getConfig();
       DurableClientAttributes dac = null;
       if (config.getDurableClientId() != null) {
@@ -1360,13 +1355,6 @@ public class LonerDistributionManager implements DistributionManager {
   }
 
   @Override
-  public Set<InetAddress> getEquivalents(InetAddress in) {
-    Set<InetAddress> value = new HashSet<InetAddress>();
-    value.add(this.getId().getInetAddress());
-    return value;
-  }
-
-  @Override
   public Set<DistributedMember> getGroupMembers(String group) {
     if (getDistributionManagerId().getGroups().contains(group)) {
       return Collections.singleton(getDistributionManagerId());
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/InternalDistributedMember.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/InternalDistributedMember.java
index c44ed2c..46cadb5 100755
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/InternalDistributedMember.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/InternalDistributedMember.java
@@ -312,7 +312,7 @@ public class InternalDistributedMember
     memberIdentifier.setProcessId(OSProcess.getId());
     try {
       if (SocketCreator.resolve_dns) {
-        setHostName(LocalHostUtil.getLocalHost().getHostName());
+        setHostName(LocalHostUtil.getLocalHostName());
       } else {
         setHostName(LocalHostUtil.getLocalHost().getHostAddress());
       }
diff --git a/geode-core/src/main/java/org/apache/geode/internal/VersionDescription.java b/geode-core/src/main/java/org/apache/geode/internal/VersionDescription.java
index 89f87f9..f0a7b28 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/VersionDescription.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/VersionDescription.java
@@ -138,7 +138,7 @@ public class VersionDescription {
 
   private static String getLocalHost() {
     try {
-      return LocalHostUtil.getLocalHost().toString();
+      return LocalHostUtil.getLocalHostString();
     } catch (UnknownHostException e) {
       return e.getMessage();
     }
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 3a10052..639dd8a 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
@@ -2747,7 +2747,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
   private PoolFactory createDefaultPF() {
     PoolFactory defaultPoolFactory = PoolManager.createFactory();
     try {
-      String localHostName = LocalHostUtil.getLocalHost().getHostName();
+      String localHostName = LocalHostUtil.getLocalHostName();
       defaultPoolFactory.addServer(localHostName, CacheServer.DEFAULT_PORT);
     } catch (UnknownHostException ex) {
       throw new IllegalStateException("Could not determine local host name", ex);
@@ -2772,7 +2772,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
     if (poolFactoryImpl.getPoolAttributes().locators.isEmpty()
         && poolFactoryImpl.getPoolAttributes().servers.isEmpty()) {
       try {
-        String localHostName = LocalHostUtil.getLocalHost().getHostName();
+        String localHostName = LocalHostUtil.getLocalHostName();
         poolFactoryImpl.addServer(localHostName, CacheServer.DEFAULT_PORT);
       } catch (UnknownHostException ex) {
         throw new IllegalStateException("Could not determine local host name", ex);
diff --git a/geode-core/src/main/java/org/apache/geode/internal/net/SocketCreator.java b/geode-core/src/main/java/org/apache/geode/internal/net/SocketCreator.java
index 333c74f..9468ef2 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/net/SocketCreator.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/net/SocketCreator.java
@@ -187,6 +187,12 @@ public class SocketCreator extends TcpSocketCreatorImpl {
     initialize();
   }
 
+  /** returns the hostname or address for this client */
+  public static String getClientHostName() throws UnknownHostException {
+    InetAddress hostAddr = LocalHostUtil.getLocalHost();
+    return SocketCreator.use_client_host_name ? hostAddr.getCanonicalHostName()
+        : hostAddr.getHostAddress();
+  }
 
   // -------------------------------------------------------------------------
   // Initializers (change SocketCreator state)
diff --git a/geode-core/src/main/java/org/apache/geode/internal/statistics/HostStatSampler.java b/geode-core/src/main/java/org/apache/geode/internal/statistics/HostStatSampler.java
index 2e16264..c35a50c 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/statistics/HostStatSampler.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/statistics/HostStatSampler.java
@@ -152,7 +152,7 @@ public abstract class HostStatSampler
   @Override
   public String getSystemDirectoryPath() {
     try {
-      return LocalHostUtil.getLocalHost().getHostName();
+      return LocalHostUtil.getLocalHostName();
     } catch (UnknownHostException ignore) {
       return "";
     }
diff --git a/geode-core/src/main/java/org/apache/geode/internal/statistics/OsStatisticsProvider.java b/geode-core/src/main/java/org/apache/geode/internal/statistics/OsStatisticsProvider.java
index 06d1bad..d274bf1 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/statistics/OsStatisticsProvider.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/statistics/OsStatisticsProvider.java
@@ -14,7 +14,6 @@
  */
 package org.apache.geode.internal.statistics;
 
-import java.net.InetAddress;
 import java.net.UnknownHostException;
 
 import org.apache.geode.Statistics;
@@ -132,12 +131,10 @@ public class OsStatisticsProvider {
    * @return this machine's fully qualified hostname or "unknownHostName" if one cannot be found.
    */
   private String getHostSystemName() {
-    String hostname = "unknownHostName";
     try {
-      InetAddress inetAddress = LocalHostUtil.getLocalHost();
-      hostname = inetAddress.getCanonicalHostName();
+      return LocalHostUtil.getCanonicalLocalHostName();
     } catch (UnknownHostException ignored) {
     }
-    return hostname;
+    return "unknownHostName";
   }
 }
diff --git a/geode-core/src/main/java/org/apache/geode/internal/statistics/StatArchiveWriter.java b/geode-core/src/main/java/org/apache/geode/internal/statistics/StatArchiveWriter.java
index 074da02..eb1dbea 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/statistics/StatArchiveWriter.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/statistics/StatArchiveWriter.java
@@ -203,7 +203,7 @@ public class StatArchiveWriter implements StatArchiveFormat, SampleHandler {
   protected String getMachineInfo() {
     String machineInfo = System.getProperty("os.arch");
     try {
-      String hostName = LocalHostUtil.getLocalHost().getHostName();
+      String hostName = LocalHostUtil.getLocalHostName();
       machineInfo += " " + hostName;
     } catch (UnknownHostException ignore) {
     }
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/ManagementAgent.java b/geode-core/src/main/java/org/apache/geode/management/internal/ManagementAgent.java
index 247c5e5..2889194 100755
--- a/geode-core/src/main/java/org/apache/geode/management/internal/ManagementAgent.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/ManagementAgent.java
@@ -311,7 +311,7 @@ public class ManagementAgent {
     final String hostname;
     final InetAddress bindAddr;
     if (StringUtils.isBlank(this.config.getJmxManagerBindAddress())) {
-      hostname = LocalHostUtil.getLocalHost().getHostName();
+      hostname = LocalHostUtil.getLocalHostName();
       bindAddr = null;
     } else {
       hostname = this.config.getJmxManagerBindAddress();
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/beans/MemberMBeanBridge.java b/geode-core/src/main/java/org/apache/geode/management/internal/beans/MemberMBeanBridge.java
index 5daa606..859f425 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/beans/MemberMBeanBridge.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/beans/MemberMBeanBridge.java
@@ -212,7 +212,7 @@ public class MemberMBeanBridge {
     initGemfireProperties();
 
     try {
-      hostname = LocalHostUtil.getLocalHost().getHostName();
+      hostname = LocalHostUtil.getLocalHostName();
     } catch (UnknownHostException ignore) {
       hostname = ManagementConstants.DEFAULT_HOST_NAME;
     }
diff --git a/geode-junit/src/main/java/org/apache/geode/codeAnalysis/AnalyzeSerializablesJUnitTestBase.java b/geode-junit/src/main/java/org/apache/geode/codeAnalysis/AnalyzeSerializablesJUnitTestBase.java
index d30e1c5..fab4dd8 100644
--- a/geode-junit/src/main/java/org/apache/geode/codeAnalysis/AnalyzeSerializablesJUnitTestBase.java
+++ b/geode-junit/src/main/java/org/apache/geode/codeAnalysis/AnalyzeSerializablesJUnitTestBase.java
@@ -31,11 +31,8 @@ import java.io.InvalidClassException;
 import java.io.Serializable;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Modifier;
-import java.nio.file.Paths;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedList;
 import java.util.List;
@@ -43,8 +40,8 @@ import java.util.Map;
 import java.util.Properties;
 import java.util.ServiceLoader;
 import java.util.Set;
-import java.util.stream.Collectors;
 
+import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
@@ -65,6 +62,7 @@ import org.apache.geode.internal.InternalDataSerializer;
 import org.apache.geode.internal.serialization.Version;
 import org.apache.geode.pdx.internal.TypeRegistry;
 import org.apache.geode.test.junit.categories.SerializationTest;
+import org.apache.geode.test.junit.rules.ClassAnalysisRule;
 import org.apache.geode.unsafe.internal.sun.reflect.ReflectionFactory;
 
 @Category({SerializationTest.class})
@@ -96,6 +94,9 @@ public abstract class AnalyzeSerializablesJUnitTestBase {
   @Rule
   public TestName testName = new TestName();
 
+  @Rule
+  public ClassAnalysisRule classProvider = new ClassAnalysisRule(getModuleName());
+
   private void loadExpectedDataSerializables() throws Exception {
     this.expectedDataSerializablesFile = getResourceAsFile("sanctionedDataSerializables.txt");
     assertThat(this.expectedDataSerializablesFile).exists().canRead();
@@ -114,20 +115,25 @@ public abstract class AnalyzeSerializablesJUnitTestBase {
   }
 
   public void findClasses() throws Exception {
-    this.classes = new HashMap<>();
+    classes = classProvider.getClasses();
+
+    List<String> excludedClasses = loadExcludedClasses(getResourceAsFile(EXCLUDED_CLASSES_TXT));
+    List<String> openBugs = loadOpenBugs(getResourceAsFile(OPEN_BUGS_TXT));
 
-    loadClasses();
+    excludedClasses.addAll(openBugs);
+    removeExclusions(classes, excludedClasses);
   }
 
   @Before
   public void setUp() throws Exception {
-    // assumeThat(
-    // "AnalyzeSerializables requires Java 8 but tests are running with v"
-    // + SystemUtils.JAVA_VERSION,
-    // isJavaVersionAtLeast(JavaVersion.JAVA_1_8), is(true));
     TypeRegistry.init();
   }
 
+  @AfterClass
+  public static void afterClass() {
+    ClassAnalysisRule.clearCache();
+  }
+
   private List<DistributedSystemService> initializeServices() {
     ServiceLoader<DistributedSystemService> loader =
         ServiceLoader.load(DistributedSystemService.class);
@@ -413,51 +419,6 @@ public abstract class AnalyzeSerializablesJUnitTestBase {
         "src" + File.separator + testOrMain + File.separator + "resources");
   }
 
-  private void loadClasses() throws IOException {
-    System.out.println("loadClasses starting");
-
-    List<String> excludedClasses = loadExcludedClasses(getResourceAsFile(EXCLUDED_CLASSES_TXT));
-    List<String> openBugs = loadOpenBugs(getResourceAsFile(OPEN_BUGS_TXT));
-
-    excludedClasses.addAll(openBugs);
-
-    String classpath = System.getProperty("java.class.path");
-    System.out.println("java classpath is " + classpath);
-
-    List<File> entries =
-        Arrays.stream(classpath.split(File.pathSeparator)).map(x -> new File(x)).collect(
-            Collectors.toList());
-    String gradleBuildDirName =
-        Paths.get(getModuleName(), "build", "classes", "java", "main").toString();
-    System.out.println("gradleBuildDirName is " + gradleBuildDirName);
-    String ideaBuildDirName = Paths.get(getModuleName(), "out", "production", "classes").toString();
-    System.out.println("ideaBuildDirName is " + ideaBuildDirName);
-    String ideaFQCNBuildDirName = Paths.get("out", "production",
-        "geode." + getModuleName() + ".main").toString();
-    System.out.println("idea build path with full package names is " + ideaFQCNBuildDirName);
-    String buildDir = null;
-
-    for (File entry : entries) {
-      System.out.println("examining '" + entry + "'");
-      if (entry.toString().endsWith(gradleBuildDirName)
-          || entry.toString().endsWith(ideaBuildDirName)
-          || entry.toString().endsWith(ideaFQCNBuildDirName)) {
-        buildDir = entry.toString();
-        break;
-      }
-    }
-
-    assertThat(buildDir).isNotNull();
-    System.out.println("loading class files from " + buildDir);
-
-    long start = System.currentTimeMillis();
-    loadClassesFromBuild(new File(buildDir), excludedClasses);
-    long finish = System.currentTimeMillis();
-
-    System.out.println("done loading " + this.classes.size() + " classes.  elapsed time = "
-        + (finish - start) / 1000 + " seconds");
-  }
-
   private List<String> loadExcludedClasses(File exclusionsFile) throws IOException {
     List<String> excludedClasses = new LinkedList<>();
     FileReader fr = new FileReader(exclusionsFile);
@@ -506,12 +467,6 @@ public abstract class AnalyzeSerializablesJUnitTestBase {
     }
   }
 
-  private void loadClassesFromBuild(File buildDir, List<String> excludedClasses) {
-    Map<String, CompiledClass> newClasses = CompiledClassUtils.parseClassFilesInDir(buildDir);
-    removeExclusions(newClasses, excludedClasses);
-    this.classes.putAll(newClasses);
-  }
-
   private List<ClassAndMethods> findToDatasAndFromDatas() {
     List<ClassAndMethods> result = new ArrayList<>();
     for (Map.Entry<String, CompiledClass> entry : this.classes.entrySet()) {
diff --git a/geode-junit/src/main/java/org/apache/geode/codeAnalysis/decode/CompiledClass.java b/geode-junit/src/main/java/org/apache/geode/codeAnalysis/decode/CompiledClass.java
index af55f1d..4060e5d 100644
--- a/geode-junit/src/main/java/org/apache/geode/codeAnalysis/decode/CompiledClass.java
+++ b/geode-junit/src/main/java/org/apache/geode/codeAnalysis/decode/CompiledClass.java
@@ -29,13 +29,22 @@ import org.apache.geode.codeAnalysis.decode.cp.Cp;
 import org.apache.geode.codeAnalysis.decode.cp.CpClass;
 import org.apache.geode.codeAnalysis.decode.cp.CpDouble;
 import org.apache.geode.codeAnalysis.decode.cp.CpLong;
+import org.apache.geode.codeAnalysis.decode.cp.CpMethodref;
 import org.apache.geode.internal.ExitCode;
 import org.apache.geode.internal.logging.PureLogWriter;
 import org.apache.geode.internal.serialization.DataSerializableFixedID;
 
 
 /**
- * Decoder represents a jdk ClassFile header
+ * Decoder represents a jdk ClassFile header. See "The Java Virtual Machine Specification"
+ * for a detailed description of all of the fields in this and other classes in this
+ * package and the "cp" (constant pool) package
+ * <p>
+ * Basically, all of the other classes hold indexes into one of the fields in this
+ * class. Cp classes hold indexes into the constant_pool, which holds all of the Cp
+ * instances associated with this CompiledClass. A CpMethodref, for instance, holds an
+ * index into the constant_pool to locate the CpClass implementing the method as well
+ * as an index into the constant_pool of the CpNameAndType of the method itself.
  */
 
 public class CompiledClass implements Comparable {
@@ -256,4 +265,26 @@ public class CompiledClass implements Comparable {
     ExitCode.NORMAL.doSystemExit();
   }
 
+  public boolean refersToClass(String name) {
+    for (Cp constantPoolEntry : constant_pool) {
+      if (constantPoolEntry instanceof CpClass &&
+          ((CpClass) constantPoolEntry).className(this).equals(name)) {
+        return true;
+      }
+    }
+    return false;
+  }
+
+  public boolean refersToMethod(String className, String methodName) {
+    for (Cp constantPoolEntry : constant_pool) {
+      if (constantPoolEntry instanceof CpMethodref) {
+        CpMethodref methodref = (CpMethodref) constantPoolEntry;
+        if (methodref.className(this).equals(className)
+            && methodref.methodName(this).equals(methodName)) {
+          return true;
+        }
+      }
+    }
+    return false;
+  }
 }
diff --git a/geode-junit/src/main/java/org/apache/geode/codeAnalysis/decode/cp/CpFieldref.java b/geode-junit/src/main/java/org/apache/geode/codeAnalysis/decode/cp/CpFieldref.java
index 0602243..225d79a 100644
--- a/geode-junit/src/main/java/org/apache/geode/codeAnalysis/decode/cp/CpFieldref.java
+++ b/geode-junit/src/main/java/org/apache/geode/codeAnalysis/decode/cp/CpFieldref.java
@@ -29,6 +29,14 @@ public class CpFieldref extends Cp {
     name_and_type_index = source.readUnsignedShort();
   }
 
+  public String className(CompiledClass info) {
+    return ((CpClass) info.constant_pool[class_index]).className(info);
+  }
+
+  public String methodName(CompiledClass info) {
+    return ((CpNameAndType) info.constant_pool[name_and_type_index]).name(info);
+  }
+
   public String returnType(CompiledClass info) {
     return "not yet implemented";
   }
diff --git a/geode-junit/src/main/java/org/apache/geode/codeAnalysis/decode/cp/CpMethodref.java b/geode-junit/src/main/java/org/apache/geode/codeAnalysis/decode/cp/CpMethodref.java
index e2ef8c9..55d03ea 100644
--- a/geode-junit/src/main/java/org/apache/geode/codeAnalysis/decode/cp/CpMethodref.java
+++ b/geode-junit/src/main/java/org/apache/geode/codeAnalysis/decode/cp/CpMethodref.java
@@ -18,6 +18,7 @@ import java.io.DataInputStream;
 import java.io.IOException;
 
 
+
 public class CpMethodref extends CpFieldref {
   CpMethodref(DataInputStream source) throws IOException {
     super(source);
diff --git a/geode-junit/src/main/java/org/apache/geode/codeAnalysis/decode/cp/CpNameAndType.java b/geode-junit/src/main/java/org/apache/geode/codeAnalysis/decode/cp/CpNameAndType.java
index 79474bc..85077fa 100644
--- a/geode-junit/src/main/java/org/apache/geode/codeAnalysis/decode/cp/CpNameAndType.java
+++ b/geode-junit/src/main/java/org/apache/geode/codeAnalysis/decode/cp/CpNameAndType.java
@@ -17,6 +17,8 @@ package org.apache.geode.codeAnalysis.decode.cp;
 import java.io.DataInputStream;
 import java.io.IOException;
 
+import org.apache.geode.codeAnalysis.decode.CompiledClass;
+
 public class CpNameAndType extends Cp {
   int name_index; // utf8 unqualified field/method name
   int descriptor_index; // utf8
@@ -25,4 +27,12 @@ public class CpNameAndType extends Cp {
     name_index = source.readUnsignedShort();
     descriptor_index = source.readUnsignedShort();
   }
+
+  public String name(CompiledClass info) {
+    return ((CpUtf8) info.constant_pool[name_index]).stringValue();
+  }
+
+  public String type(CompiledClass info) {
+    return ((CpUtf8) info.constant_pool[descriptor_index]).stringValue();
+  }
 }
diff --git a/geode-membership/src/integrationTest/java/org/apache/geode/distributed/internal/membership/gms/locator/GMSLocatorRecoveryIntegrationTest.java b/geode-membership/src/integrationTest/java/org/apache/geode/distributed/internal/membership/gms/locator/GMSLocatorRecoveryIntegrationTest.java
index 25f7dbf..79835fe 100644
--- a/geode-membership/src/integrationTest/java/org/apache/geode/distributed/internal/membership/gms/locator/GMSLocatorRecoveryIntegrationTest.java
+++ b/geode-membership/src/integrationTest/java/org/apache/geode/distributed/internal/membership/gms/locator/GMSLocatorRecoveryIntegrationTest.java
@@ -163,7 +163,7 @@ public class GMSLocatorRecoveryIntegrationTest {
       MembershipConfig membershipConfig = new MembershipConfig() {
         public String getLocators() {
           try {
-            return LocalHostUtil.getLocalHost().getHostName() + "[" + port + "]";
+            return LocalHostUtil.getLocalHostName() + "[" + port + "]";
           } catch (UnknownHostException e) {
             throw new RuntimeException("unable to locate localhost for this machine");
           }
diff --git a/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/locator/MembershipLocatorImpl.java b/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/locator/MembershipLocatorImpl.java
index 3bb89d7..7cb5b6a 100644
--- a/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/locator/MembershipLocatorImpl.java
+++ b/geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/gms/locator/MembershipLocatorImpl.java
@@ -72,7 +72,7 @@ public class MembershipLocatorImpl<ID extends MemberIdentifier> implements Membe
       MembershipConfig config)
       throws MembershipConfigurationException, UnknownHostException {
     handler = new PrimaryHandler(fallbackHandler, config.getLocatorWaitTime());
-    String host = bindAddress == null ? LocalHostUtil.getLocalHost().getHostName()
+    String host = bindAddress == null ? LocalHostUtil.getLocalHostName()
         : bindAddress.getHostName();
     String threadName = "Distribution Locator on " + host + ": " + port;
 
diff --git a/geode-tcp-server/src/distributedTest/java/org/apache/geode/distributed/internal/tcpserver/TcpServerGossipVersionDUnitTest.java b/geode-tcp-server/src/distributedTest/java/org/apache/geode/distributed/internal/tcpserver/TcpServerGossipVersionDUnitTest.java
index f321a9a..1572866 100644
--- a/geode-tcp-server/src/distributedTest/java/org/apache/geode/distributed/internal/tcpserver/TcpServerGossipVersionDUnitTest.java
+++ b/geode-tcp-server/src/distributedTest/java/org/apache/geode/distributed/internal/tcpserver/TcpServerGossipVersionDUnitTest.java
@@ -149,7 +149,7 @@ public class TcpServerGossipVersionDUnitTest extends JUnit4DistributedTestCase {
           .getSocketCreatorForComponent(SecurableCommunicationChannel.LOCATOR),
           InternalDataSerializer.getDSFIDSerializer().getObjectSerializer(),
           InternalDataSerializer.getDSFIDSerializer().getObjectDeserializer())
-              .requestToServer(new HostAndPort(LocalHostUtil.getLocalHost().getHostName(), port0),
+              .requestToServer(new HostAndPort(LocalHostUtil.getLocalHostName(), port0),
                   req, 5000);
       assertThat(response).isNotNull();
 
diff --git a/geode-wan/src/distributedTest/java/org/apache/geode/internal/cache/wan/serial/WANHostNameVerificationDistributedTest.java b/geode-wan/src/distributedTest/java/org/apache/geode/internal/cache/wan/serial/WANHostNameVerificationDistributedTest.java
index 27ce3ff..d9d4fd7 100644
--- a/geode-wan/src/distributedTest/java/org/apache/geode/internal/cache/wan/serial/WANHostNameVerificationDistributedTest.java
+++ b/geode-wan/src/distributedTest/java/org/apache/geode/internal/cache/wan/serial/WANHostNameVerificationDistributedTest.java
@@ -225,7 +225,7 @@ public class WANHostNameVerificationDistributedTest {
         .commonName("server_ln")
         .issuedBy(ca)
         .sanDnsName(InetAddress.getLocalHost().getHostName())
-        .sanDnsName(LocalHostUtil.getLocalHost().getHostName())
+        .sanDnsName(LocalHostUtil.getLocalHostName())
         .sanDnsName(LocalHostUtil.getLocalHost().getCanonicalHostName())
         .sanDnsName(InetAddress.getLocalHost().getHostAddress())
         .sanIpAddress(InetAddress.getLocalHost())
@@ -240,7 +240,7 @@ public class WANHostNameVerificationDistributedTest {
         .sanDnsName(InetAddress.getLocalHost().getHostName())
         .sanDnsName(InetAddress.getLocalHost().getCanonicalHostName())
         .sanDnsName(LocalHostUtil.getLocalHost().getCanonicalHostName())
-        .sanDnsName(LocalHostUtil.getLocalHost().getHostName())
+        .sanDnsName(LocalHostUtil.getLocalHostName())
         .sanDnsName(InetAddress.getLocalHost().getHostAddress())
         .sanIpAddress(InetAddress.getLocalHost())
         .sanIpAddress(InetAddress.getByName("0.0.0.0")) // to pass on windows
@@ -252,7 +252,7 @@ public class WANHostNameVerificationDistributedTest {
         .issuedBy(ca)
         .sanDnsName(InetAddress.getLocalHost().getHostName())
         .sanDnsName(InetAddress.getLocalHost().getCanonicalHostName())
-        .sanDnsName(LocalHostUtil.getLocalHost().getHostName())
+        .sanDnsName(LocalHostUtil.getLocalHostName())
         .sanDnsName(LocalHostUtil.getLocalHost().getCanonicalHostName())
         .sanDnsName(InetAddress.getLocalHost().getHostAddress())
         .sanIpAddress(InetAddress.getLocalHost())
diff --git a/geode-wan/src/main/java/org/apache/geode/internal/cache/wan/GatewayReceiverImpl.java b/geode-wan/src/main/java/org/apache/geode/internal/cache/wan/GatewayReceiverImpl.java
index b4b5ed6..55a86da 100644
--- a/geode-wan/src/main/java/org/apache/geode/internal/cache/wan/GatewayReceiverImpl.java
+++ b/geode-wan/src/main/java/org/apache/geode/internal/cache/wan/GatewayReceiverImpl.java
@@ -119,7 +119,7 @@ public class GatewayReceiverImpl implements GatewayReceiver {
     }
 
     try {
-      return LocalHostUtil.getLocalHost().getHostName();
+      return LocalHostUtil.getLocalHostName();
     } catch (UnknownHostException e) {
       throw new IllegalStateException("Could not get host name", e);
     }
diff --git a/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/GatewayReceiverImplTest.java b/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/GatewayReceiverImplTest.java
index db99ce9..384eb49 100644
--- a/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/GatewayReceiverImplTest.java
+++ b/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/GatewayReceiverImplTest.java
@@ -64,7 +64,7 @@ public class GatewayReceiverImplTest {
     GatewayReceiver gateway = new GatewayReceiverImpl(cache, 2000, 2001, 5, 100, null, null, null,
         true, true, 2000);
 
-    assertThat(gateway.getHost()).isEqualTo(LocalHostUtil.getLocalHost().getHostName());
+    assertThat(gateway.getHost()).isEqualTo(LocalHostUtil.getLocalHostName());
   }
 
   @Test