You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kl...@apache.org on 2019/06/13 17:22:41 UTC
[geode] 01/05: GEODE-6183: Make isAttachAPIFound load providers
This is an automated email from the ASF dual-hosted git repository.
klund pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git
commit f074ca72ae9a8e76066c3ccd7ba74499ceec1743
Author: Kirk Lund <kl...@apache.org>
AuthorDate: Thu May 30 11:17:49 2019 -0700
GEODE-6183: Make isAttachAPIFound load providers
VirtualMachine class can be loaded even if AttachProvider service
providers are not found. This change forces loading of providers
for isAttachAPIFound.
Co-authored-by: Michael Oleske <mo...@pivotal.io>
---
.../geode/internal/process/ProcessControllerFactory.java | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/geode-core/src/main/java/org/apache/geode/internal/process/ProcessControllerFactory.java b/geode-core/src/main/java/org/apache/geode/internal/process/ProcessControllerFactory.java
index 3911a08..93a8238 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/process/ProcessControllerFactory.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/process/ProcessControllerFactory.java
@@ -20,6 +20,9 @@ import static org.apache.commons.lang3.Validate.notNull;
import java.io.File;
import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ServiceConfigurationError;
import java.util.concurrent.TimeoutException;
import org.apache.geode.distributed.internal.DistributionConfig;
@@ -72,9 +75,14 @@ public class ProcessControllerFactory {
}
boolean found = false;
try {
- final Class<?> virtualMachineClass = Class.forName("com.sun.tools.attach.VirtualMachine");
- found = virtualMachineClass != null;
- } catch (ClassNotFoundException ignore) {
+ final Class<?> virtualMachineClass = Class.forName("com.sun.tools.attach.spi.AttachProvider");
+ if (virtualMachineClass != null) {
+ Method providersMethod = virtualMachineClass.getMethod("providers");
+ providersMethod.invoke(virtualMachineClass);
+ found = true;
+ }
+ } catch (ClassNotFoundException | IllegalAccessException | InvocationTargetException
+ | NoSuchMethodException | ServiceConfigurationError ignore) {
}
return found;
}