Uploaded image for project: 'Commons IO'
  1. Commons IO
  2. IO-201

CountingInputStream/CountingOutputStream only partially synchronized

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.4
    • Fix Version/s: 2.0
    • Component/s: Filters
    • Labels:
      None

      Description

      CountingInputStream is only partially synchronized.

      The count is not synchronized when it is updated in read operations, so is not guaranteed to be published correctly

      The synchronization could be removed without loss of functionality.

      Not sure it makes sense to share a stream between threads anyway, as the underlying stream is unlikely to be thread-safe.

      If only one thread reads the stream, then the count field could be made volatile.
      This would allow other threads to read the count safely.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                niallp Niall Pemberton
                Reporter:
                sebb@apache.org Sebb
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: