geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject geode git commit: Remove Attach API usage from AbstractLauncher [Forced Update!]
Date Wed, 08 Mar 2017 22:14:13 GMT
Repository: geode
Updated Branches:
  refs/heads/feature/GEODE-2594 3592e81c7 -> d9d430099 (forced update)


Remove Attach API usage from AbstractLauncher


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/d9d43009
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/d9d43009
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/d9d43009

Branch: refs/heads/feature/GEODE-2594
Commit: d9d430099936b434312bc59984d5cfafda3e65d0
Parents: a0716a5
Author: Kirk Lund <klund@apache.org>
Authored: Wed Mar 8 14:13:14 2017 -0800
Committer: Kirk Lund <klund@apache.org>
Committed: Wed Mar 8 14:13:14 2017 -0800

----------------------------------------------------------------------
 .../geode/distributed/AbstractLauncher.java     | 62 +-------------------
 .../geode/distributed/AbstractLauncherTest.java | 33 +----------
 2 files changed, 6 insertions(+), 89 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/d9d43009/geode-core/src/main/java/org/apache/geode/distributed/AbstractLauncher.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/AbstractLauncher.java b/geode-core/src/main/java/org/apache/geode/distributed/AbstractLauncher.java
index 64e20f3..feba893 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/AbstractLauncher.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/AbstractLauncher.java
@@ -72,31 +72,21 @@ public abstract class AbstractLauncher<T extends Comparable<T>>
implements Runna
 
   protected static final long READ_PID_FILE_TIMEOUT_MILLIS = 2 * 1000;
 
-  // @see
-  // http://publib.boulder.ibm.com/infocenter/javasdk/v6r0/index.jsp?topic=%2Fcom.ibm.java.doc.user.lnx.60%2Fuser%2Fattachapi.html
-  // @see
-  // http://docs.oracle.com/cd/E13150_01/jrockit_jvm/jrockit/geninfo/diagnos/aboutjrockit.html#wp1083571
-  private static final List<String> ATTACH_API_PACKAGES = Arrays.asList("com.sun.tools.attach",
-      "com/sun/tools/attach", "com.ibm.tools.attach", "com/ibm/tools/attach");
-
   public static final String DEFAULT_WORKING_DIRECTORY = SystemUtils.CURRENT_DIRECTORY;
+
   public static final String SIGNAL_HANDLER_REGISTRATION_SYSTEM_PROPERTY =
       DistributionConfig.GEMFIRE_PREFIX + "launcher.registerSignalHandlers";
 
   protected static final String OPTION_PREFIX = "-";
 
-  private static final String IBM_ATTACH_API_CLASS_NAME =
-      "com.ibm.tools.attach.AgentNotSupportedException";
-  private static final String SUN_ATTACH_API_CLASS_NAME =
-      "com.sun.tools.attach.AttachNotSupportedException";
   private static final String SUN_SIGNAL_API_CLASS_NAME = "sun.misc.Signal";
 
   private volatile boolean debug;
 
   protected final transient AtomicBoolean running = new AtomicBoolean(false);
 
-  protected Logger logger = Logger.getLogger(getClass().getName()); // TODO:KIRK: does this
need
-  // log4j2?
+  // TODO: use log4j logger instead of JUL
+  protected Logger logger = Logger.getLogger(getClass().getName());
 
   public AbstractLauncher() {
     try {
@@ -197,52 +187,6 @@ public abstract class AbstractLauncher<T extends Comparable<T>>
implements Runna
   }
 
   /**
-   * This method attempts to make a best effort determination for whether the Attach API
classes are
-   * on the classpath.
-   *
-   * @param t the Throwable being evaluated for missing Attach API classes.
-   * @return a boolean indicating whether the Exception or Error condition is a result of
the Attach
-   *         API missing from the classpath.
-   */
-  protected boolean isAttachAPINotFound(final Throwable t) {
-    boolean missing = false;
-
-    // NOTE prerequisite, Throwable must be a ClassNotFoundException or NoClassDefFoundError
-    if (t instanceof ClassNotFoundException || t instanceof NoClassDefFoundError) {
-      // NOTE the use of the 'testing' class member variable, yuck!
-      if (!isAttachAPIOnClasspath()) {
-        // NOTE ok, the Attach API is not available, however we still do not know whether
an user
-        // application class
-        // caused the ClassNotFoundException or NoClassDefFoundError.
-        final StringWriter stackTraceWriter = new StringWriter();
-
-        // NOTE the full stack trace includes the Throwable message, which typically indicates
the
-        // Exception/Error
-        // thrown and the reason (as in which class was not found).
-        t.printStackTrace(new PrintWriter(stackTraceWriter));
-
-        final String stackTrace = stackTraceWriter.toString();
-
-        for (String attachApiPackage : ATTACH_API_PACKAGES) {
-          missing |= stackTrace.contains(attachApiPackage);
-        }
-      }
-    }
-
-    return missing;
-  }
-
-  /**
-   * Determines if the Attach API is on the classpath.
-   *
-   * @return a boolean value indicating if the Attach API is on the classpath.
-   */
-  boolean isAttachAPIOnClasspath() {
-    return (ClassUtils.isClassAvailable(SUN_ATTACH_API_CLASS_NAME)
-        || ClassUtils.isClassAvailable(IBM_ATTACH_API_CLASS_NAME));
-  }
-
-  /**
    * Determines whether the Locator launcher is in debug mode.
    *
    * @return a boolean to indicate whether the Locator launcher is in debug mode.

http://git-wip-us.apache.org/repos/asf/geode/blob/d9d43009/geode-core/src/test/java/org/apache/geode/distributed/AbstractLauncherTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/distributed/AbstractLauncherTest.java
b/geode-core/src/test/java/org/apache/geode/distributed/AbstractLauncherTest.java
index f487df9..feba601 100644
--- a/geode-core/src/test/java/org/apache/geode/distributed/AbstractLauncherTest.java
+++ b/geode-core/src/test/java/org/apache/geode/distributed/AbstractLauncherTest.java
@@ -14,6 +14,9 @@
  */
 package org.apache.geode.distributed;
 
+import static org.apache.geode.distributed.ConfigurationProperties.*;
+import static org.junit.Assert.*;
+
 import org.apache.geode.internal.lang.StringUtils;
 import org.apache.geode.test.junit.categories.UnitTest;
 import org.junit.Test;
@@ -24,9 +27,6 @@ import java.net.URL;
 import java.util.Properties;
 import java.util.concurrent.TimeUnit;
 
-import static org.junit.Assert.*;
-import static org.apache.geode.distributed.ConfigurationProperties.*;
-
 /**
  * The AbstractLauncherTest class is a test suite of unit tests testing the contract and
  * functionality of the AbstractLauncher class.
@@ -46,28 +46,6 @@ public class AbstractLauncherTest {
   }
 
   @Test
-  public void testIsAttachAPINotFound() {
-    final AbstractLauncher<?> launcher = createAbstractLauncher("012", "TestMember");
-
-    assertTrue(launcher.isAttachAPINotFound(new NoClassDefFoundError(
-        "Exception in thread \"main\" java.lang.NoClassDefFoundError: com/sun/tools/attach/AttachNotSupportedException")));
-    assertTrue(launcher.isAttachAPINotFound(new ClassNotFoundException(
-        "Caused by: java.lang.ClassNotFoundException: com.sun.tools.attach.AttachNotSupportedException")));
-    assertTrue(launcher.isAttachAPINotFound(new NoClassDefFoundError(
-        "Exception in thread \"main\" java.lang.NoClassDefFoundError: com/ibm/tools/attach/AgentNotSupportedException")));
-    assertTrue(launcher.isAttachAPINotFound(new ClassNotFoundException(
-        "Caused by: java.lang.ClassNotFoundException: com.ibm.tools.attach.AgentNotSupportedException")));
-    assertFalse(launcher.isAttachAPINotFound(new IllegalArgumentException(
-        "Caused by: java.lang.ClassNotFoundException: com.sun.tools.attach.AttachNotSupportedException")));
-    assertFalse(launcher.isAttachAPINotFound(new IllegalStateException(
-        "Caused by: java.lang.ClassNotFoundException: com.ibm.tools.attach.AgentNotSupportedException")));
-    assertFalse(launcher.isAttachAPINotFound(new NoClassDefFoundError(
-        "Exception in thread \"main\" java.lang.NoClassDefFoundError: com/companyx/app/service/MyServiceClass")));
-    assertFalse(launcher.isAttachAPINotFound(new ClassNotFoundException(
-        "Caused by: java.lang.ClassNotFoundException: com.companyx.app.attach.NutsNotAttachedException")));
-  }
-
-  @Test
   public void testIsSet() {
     final Properties properties = new Properties();
 
@@ -282,11 +260,6 @@ public class AbstractLauncherTest {
     }
 
     @Override
-    boolean isAttachAPIOnClasspath() {
-      return false;
-    }
-
-    @Override
     public String getLogFileName() {
       throw new UnsupportedOperationException("Not Implemented!");
     }


Mime
View raw message