You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2013/07/03 19:44:00 UTC

git commit: Fixed broken JVM tests on OS X by endabling headless mode for AWT.

Updated Branches:
  refs/heads/master d46f3e20a -> 88d7f1dc2


Fixed broken JVM tests on OS X by endabling headless mode for AWT.

Review: https://reviews.apache.org/r/12236


Project: http://git-wip-us.apache.org/repos/asf/incubator-mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mesos/commit/88d7f1dc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mesos/tree/88d7f1dc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mesos/diff/88d7f1dc

Branch: refs/heads/master
Commit: 88d7f1dc2096885574f6aacb587344b6b1976646
Parents: d46f3e2
Author: Benjamin Mahler <bm...@twitter.com>
Authored: Tue Jul 2 11:10:55 2013 -0700
Committer: Benjamin Mahler <bm...@twitter.com>
Committed: Wed Jul 3 10:43:24 2013 -0700

----------------------------------------------------------------------
 src/jvm/jvm.cpp | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mesos/blob/88d7f1dc/src/jvm/jvm.cpp
----------------------------------------------------------------------
diff --git a/src/jvm/jvm.cpp b/src/jvm/jvm.cpp
index d053f59..17ab12e 100644
--- a/src/jvm/jvm.cpp
+++ b/src/jvm/jvm.cpp
@@ -3,6 +3,7 @@
 
 #include <glog/logging.h>
 
+#include <algorithm>
 #include <map>
 #include <memory>
 #include <sstream>
@@ -21,7 +22,7 @@ Jvm* Jvm::instance = NULL;
 
 
 Try<Jvm*> Jvm::create(
-    const std::vector<std::string>& options,
+    const std::vector<std::string>& _options,
     JNI::Version version,
     bool exceptions)
 {
@@ -34,6 +35,20 @@ Try<Jvm*> Jvm::create(
   vmArgs.version = version;
   vmArgs.ignoreUnrecognized = false;
 
+  std::vector<std::string> options = _options;
+
+#ifdef __APPLE__
+  // The Apple JNI implementation requires the AWT thread to not
+  // be the main application thread. Enabling headless mode
+  // circumvents the issue. Further details:
+  // https://issues.apache.org/jira/browse/MESOS-524
+  // http://www.oracle.com/technetwork/articles/javase/headless-136834.html
+  if (std::find(options.begin(), options.end(), "-Djava.awt.headless=true")
+      == options.end()) {
+    options.push_back("-Djava.awt.headless=true");
+  }
+#endif
+
   JavaVMOption* opts = new JavaVMOption[options.size()];
   for (size_t i = 0; i < options.size(); i++) {
     opts[i].optionString = const_cast<char*>(options[i].c_str());