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

Revisit some uses of `synchronized` in the HttpClient API

XMLWordPrintable

    • b25

      The HttpClient uses synchronized at places where it is not needed - or potentially harmful.

      The Utils.remaining(List<ByteBuffer> list) method assumes that it can and should synchronize on the given list to prevent concurrent modification. In 99% of the cases this assumption is wrong. There's only one such list (the SSLFlowDelegate writeList) that requires this synchronization.
      In some circumstances, the list operated on can be one returned by List.of() which could become value-based - and that could stop working once value-based lists are implemented.

      The `SequentialScheduler.synchronizedScheduler` uses `synchronized` for visibility. It could use a Lock for the same purpose and this would make it possible to assert that there is no contention (since the logic of the SequentialScheduler should prevent contention from occurring at this place).

            dfuchs Daniel Fuchs
            dfuchs Daniel Fuchs
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: