On Tue, 21 Jun 2022 17:31:59 GMT, Brent Christian <bchri...@openjdk.org> wrote:
>> Hi, >> >> Please find here a patch that should help the HttpClient's SelectorManager >> thread to terminate more timely, allowing the resources consumed by the >> client to be released earlier. >> >> The idea is to use a Cleaner registered with the HttpClientFacade to wakeup >> the Selector when the facade is being gc'ed. >> Some tests have been modified to wait for the selector manager thread to >> shutdown, and some of them have been observed to timeout when the fix is not >> in place. > > test/jdk/java/net/httpclient/AsFileDownloadTest.java line 207: > >> 205: System.gc(); >> 206: if (queue.remove(100) == ref) break; >> 207: } > > You might consider using the ForceGC test utility, here and in > DigestEchoClient.java. E.g.: > > * @library /test/lib/ > ... > ForceGC gc = new ForceGC(); > gc.await(ref.refersTo(null)); Well - no - because ForceGC is using a different object and a different Cleaner thread. So it's much more efficient to wait on the reference queue (= the time to wait will be shorter, so risks of exceeding the global jtreg timeout will be lower). ------------- PR: https://git.openjdk.org/jdk/pull/9217