Uploaded image for project: 'Hadoop Common'
  1. Hadoop Common
  2. HADOOP-14586

StringIndexOutOfBoundsException breaks org.apache.hadoop.util.Shell on 2.7.x with Java 9

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 2.7.2
    • 2.7.4
    • common
    • Java 9, build 175 (Java 9 release candidate as of June 25th, 2017)

    • Reviewed

    Description

      You cannot use any pre-Hadoop 2.8 component anymore with the latest release candidate build of Java 9, because it fails with an StringIndexOutOfBoundsException in org.apache.hadoop.util.Shell#<clinit>. This leads to a whole cascade of failing classes (next in chain is StringUtils).

      The reason is that the release candidate build of Java 9 no longer has "-ea" in the version string and the system property "java.version" is now simply "9". This causes the following line to fail fatally:

        private static boolean IS_JAVA7_OR_ABOVE =
            System.getProperty("java.version").substring(0, 3).compareTo("1.7") >= 0;
      

      Analysis:

      • This code looks wrong, as comparing a version this way is incorrect.
      • The substring(0, 3) is not needed, compareTo also works without it, although it is still an invalid way to compare a version.

      Attachments

        1. HADOOP-14586-branch-2.7-01.patch
          8 kB
          Akira Ajisaka
        2. HADOOP-14586-branch-2.7-02.patch
          0.8 kB
          Uwe Schindler
        3. HADOOP-14586-branch-2.7-03.patch
          0.9 kB
          Konstantin Shvachko

        Issue Links

          Activity

            People

              aajisaka Akira Ajisaka
              uschindler Uwe Schindler
              Votes:
              0 Vote for this issue
              Watchers:
              10 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: