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

PipedInputStream sleeps in awaitSpace() for too long

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 8u31
    • core-libs
    • x86_64
    • linux

      FULL PRODUCT VERSION :
      java version "1.8.0_31"
      Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
      Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Linux hostname 3.18.4-1-ARCH #1 SMP PREEMPT Tue Jan 27 20:45:02 CET 2015 x86_64 GNU/Linux

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Nothing relevant to add.

      A DESCRIPTION OF THE PROBLEM :
      If a pair of PipedInputStream and PipedOutputStream has a full pipe and the writer is waiting for the pipe to free up, PipedInputStream.awaitSpace() uses sleep(1000) and loops. If meanwhile the reader reads (making space in the pipe), the writer is not notified and sleeps for up to 1000 ms too long. This can have a high impact on time-critical applications.

      I've provided a minimal example: https://github.com/michael-borkowski/java-piped-streams-test

      I've also double-checked on StackOverflow to verify that I'm not misunderstanding something.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Please see the minimal example - I've included a lot of information, including a suggested fix: https://github.com/michael-borkowski/java-piped-streams-test


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      Please see the minimal example - I've included a lot of information, including a suggested fix: https://github.com/michael-borkowski/java-piped-streams-test
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      The only workaround I found was to build an own copy of PipedInputStream and PipedOutputStream with fix I suggested and use it as a Drop-In replacement for PipedInputStream.

            prappo Pavel Rappo
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: