Browse Source

HADOOP-11924. Tolerate JDK-8047340-related exceptions in Shell#isSetSidAvailable preventing class init. (Tsuyoshi Ozawa via gera)

(cherry picked from commit 9f6d67844da3c6ca1de66d426790e741e77f8038)
Gera Shegalov 10 năm trước cách đây
mục cha
commit
2cc2488164

+ 3 - 0
hadoop-common-project/hadoop-common/CHANGES.txt

@@ -339,6 +339,9 @@ Release 2.8.0 - UNRELEASED
     HADOOP-11994. smart-apply-patch wrongly assumes that git is infallible.
     (Kengo Seki via Arpit Agarwal)
 
+    HADOOP-11924. Tolerate JDK-8047340-related exceptions in
+    Shell#isSetSidAvailable preventing class init. (Tsuyoshi Ozawa via gera)
+
 Release 2.7.1 - UNRELEASED
 
   INCOMPATIBLE CHANGES

+ 10 - 1
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/Shell.java

@@ -392,7 +392,16 @@ abstract public class Shell {
     } catch (IOException ioe) {
       LOG.debug("setsid is not available on this machine. So not using it.");
       setsidSupported = false;
-    } finally { // handle the exit code
+    }  catch (Error err) {
+      if (err.getMessage().contains("posix_spawn is not " +
+          "a supported process launch mechanism")
+          && (Shell.FREEBSD || Shell.MAC)) {
+        // HADOOP-11924: This is a workaround to avoid failure of class init
+        // by JDK issue on TR locale(JDK-8047340).
+        LOG.info("Avoiding JDK-8047340 on BSD-based systems.", err);
+        setsidSupported = false;
+      }
+    }  finally { // handle the exit code
       if (LOG.isDebugEnabled()) {
         LOG.debug("setsid exited with exit code "
                  + (shexec != null ? shexec.getExitCode() : "(null executor)"));

+ 0 - 3
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestStringUtils.java

@@ -417,9 +417,6 @@ public class TestStringUtils extends UnitTestcaseTimeLimit {
 
   @Test
   public void testLowerAndUpperStrings() {
-    // Due to java bug http://bugs.java.com/bugdatabase/view_bug.do?bug_id=8047340,
-    // The test will fail with Turkish locality on Mac OS.
-    Assume.assumeTrue(Shell.LINUX);
     Locale defaultLocale = Locale.getDefault();
     try {
       Locale.setDefault(new Locale("tr", "TR"));