RFR: 8308310: HttpClient: Avoid logging or locking from within synchronized blocks [v5]

Andrey Turbanov aturbanov at openjdk.org
Thu May 18 16:15:59 UTC 2023


On Thu, 18 May 2023 15:07:04 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:

>> Please find here a change that revisits usage of monitors in the HttpClient.
>> 
>> With Virtual Threads now part of the platform it should be possible to pass a newVirtualThreadPerTaskExecutor to the HttpClient. Logging, when enabled, and when called from a synchronized block, can cause the carrier thread to get pinned in case of contention when printing through the underlying PrintStream.
>> 
>> This change aims at avoiding situations where the carrier threads might get pinned.
>
> Daniel Fuchs has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Add debug traces to ExpectContinueTest.java

src/java.net.http/share/classes/jdk/internal/net/http/Http1Response.java line 125:

> 123:         // state & 0x02 != 0 => tryRelease called
> 124:         volatile byte state;
> 125:         ClientRefCountTracker(HttpClientImpl client, Logger logger) {

let's add an empty line before constructor to make distinguishing more easy

src/java.net.http/share/classes/jdk/internal/net/http/Stream.java line 154:

> 152:     // send lock: prevent sending DataFrames after reset occurred.
> 153:     private final Lock sendLock = new ReentrantLock();
> 154:     final Lock stateLock = new ReentrantLock();

can it be `private` too?

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/14038#discussion_r1198013994
PR Review Comment: https://git.openjdk.org/jdk/pull/14038#discussion_r1198011072


More information about the net-dev mailing list