Commons IO
  1. Commons IO
  2. IO-201

CountingInputStream/CountingOutputStream only partially synchronized

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major 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.

        Issue Links

          Activity

          Sebb created issue -
          Sebb made changes -
          Field Original Value New Value
          Summary CountingInputStream is partially synchronized CountingInputStream/CountingOutputStream only partially synchronized
          Niall Pemberton made changes -
          Fix Version/s 2.x [ 12312838 ]
          Niall Pemberton made changes -
          Link This issue is related to IO-214 [ IO-214 ]
          Niall Pemberton made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Assignee Niall Pemberton [ niallp ]
          Fix Version/s 2.0 [ 12312961 ]
          Fix Version/s 2.x [ 12312838 ]
          Resolution Fixed [ 1 ]
          Mark Thomas made changes -
          Workflow jira [ 12457389 ] Default workflow, editable Closed status [ 12601889 ]
          Henri Yandell made changes -
          Status Resolved [ 5 ] Closed [ 6 ]

            People

            • Assignee:
              Niall Pemberton
              Reporter:
              Sebb
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development