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

Fix java.io.ObjectInputStream.PeekInputStream#skip

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 9
    • 9
    • core-libs
    • None

        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.

              prappo Pavel Rappo (Inactive)
              prappo Pavel Rappo (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: