Uploaded image for project: 'Harmony'
  1. Harmony
  2. HARMONY-6669

[classlib][archive] java.util.jar.InitManifest throws IndexOutOfBoundException when reading special Manifest file

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 5.0M16
    • Classlib
    • None
    • WinXP SP3 x86
    • Patch Available

    Description

      java.util.jar.InitManifest throws IndexOutOfBoundException when reading special Manifest file while RI will work fine.

      This bug can be recreated with the following simple test case and the attached MANIFEST.MF which is created based on the manifest file from archive.jar of Harmony.
      File file = new File("MANIFEST.MF");
      try {
      FileInputStream fis = new FileInputStream(file);
      Manifest manifest = new Manifest(fis);

      The root cause is one space character (' ') occurs in front of the line break characters (\r,\n) at the last line of the manifest file.

      Full stack trace:
      java.lang.IndexOutOfBoundsException
      at java.nio.ByteBuffer.wrap(ByteBuffer.java:106)
      at java.util.jar.InitManifest.decode(InitManifest.java:214)
      at java.util.jar.InitManifest.readValue(InitManifest.java:171)
      at java.util.jar.InitManifest.readHeader(InitManifest.java:117)
      at java.util.jar.InitManifest.<init>(InitManifest.java:55)
      at java.util.jar.Manifest.read(Manifest.java:231)
      at java.util.jar.Manifest.<init>(Manifest.java:95)
      at InitManifestTest.test_StandAloneManifest(InitManifestTest.java:23)
      at java.lang.reflect.Method.invokeImpl(Native Method)
      at java.lang.reflect.Method.invoke(Method.java:228)
      at junit.framework.TestCase.runTest(TestCase.java:168)
      at junit.framework.TestCase.runBare(TestCase.java:134)
      at junit.framework.TestResult$1.protect(TestResult.java:110)
      at junit.framework.TestResult.runProtected(TestResult.java:128)
      at junit.framework.TestResult.run(TestResult.java:113)
      at junit.framework.TestCase.run(TestCase.java:124)
      at junit.framework.TestSuite.runTest(TestSuite.java:232)
      at junit.framework.TestSuite.run(TestSuite.java:227)
      at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

      Attachments

        1. MANIFEST.MF
          1 kB
          Jonathan Lu
        2. InitManifest.diff
          0.6 kB
          Jonathan Lu

        Activity

          People

            tellison Tim Ellison
            lucaca Jonathan Lu
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: