Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8067870

Fix java.io.ObjectInputStream.PeekInputStream#skip

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 9
    • Fix Version/s: 9
    • Component/s: core-libs
    • Labels:
      None

      Backports

        Description

        A small typo makes skipping behave incorrectly and in the worst case scenario
        leads to an infinite recursion:

                public long skip(long n) throws IOException {
                    if (n <= 0) {
                        return 0;
                    }
                    int skipped = 0;
                    if (peekb >= 0) {
                        peekb = -1;
                        skipped++;
                        n--;
                    }
                    return skipped + skip(n);
                }

        The last line should have been like this:

                    return skipped + in.skip(n);

        The method doesn't seem to be used by its enclosing classes. I also haven't
        found any evidence an instance of PeekInputStream can escape. Nevertheless I
        believe this typo should be fixed.

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                prappo Pavel Rappo
                Reporter:
                prappo Pavel Rappo
                Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: