[
https://issues.apache.org/jira/browse/CXF-8987?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Andriy Redko resolved CXF-8987.
-------------------------------
Resolution: Fixed
> Java 21 - HttpClientHTTPConduit thread locked during shutdown
> --------------------------------------------------------------
>
> Key: CXF-8987
> URL: https://issues.apache.org/jira/browse/CXF-8987
> Project: CXF
> Issue Type: Bug
> Components: Transports
> Affects Versions: 4.0.3, 4.0.4
> Environment: [^thdump2]
> *OpenJDK 21.0.2*
> *Apache CXF 4.0.4*
> *Apache Camel 4.4.1*
> Reporter: Giacomo Carnevale
> Assignee: Andriy Redko
> Priority: Blocker
> Fix For: 4.1.0, 4.0.5, 3.6.4
>
> Attachments: thdump2
>
>
> Hi,
> I am using Apache CXF client via the Apache Camel CXF connector.
> After I updated frm OpenJDK 17.x to OpenJDK 21.0.2, during application
> shutdown, the following lock occurs:
> *at java.lang.Thread.join([email protected]/Thread.java:2072)*
> *- locked <0x000000061cd2ab80> (a
> jdk.internal.net.http.HttpClientImpl$SelectorManager)*
> *at java.lang.Thread.join([email protected]/Thread.java:2200)*
> *at
> jdk.internal.net.http.HttpClientImpl.awaitTermination([email protected]/HttpClientImpl.java:628)*
> *at
> java.net.http.HttpClient.{color:#de350b}close{color}([email protected]/HttpClient.java:900)*
> *at
> jdk.internal.net.http.HttpClientFacade.{color:#de350b}close{color}([email protected]/HttpClientFacade.java:192)*
> *at
> org.apache.cxf.transport.http.HttpClientHTTPConduit.{color:#de350b}close{color}(HttpClientHTTPConduit.java:125)*
> HttpClientHTTPConduit.close
> {code:java}
> public void close() {
> if (client instanceof AutoCloseable) {
> try {
> ((AutoCloseable)client).close();
> } catch (Exception e) {
> //ignore
> }
> } else if (client != null) {
> String name = client.toString();
> client = null;
> tryToShutdownSelector(name);
> }
> defaultAddress = null;
> super.close();
> } {code}
>
> java.net.HttpClient.close
>
> {code:java}
> public void close() {
> boolean terminated = isTerminated();
> if (!terminated) {
> shutdown();
> boolean interrupted = false;
> while (!terminated) {
> try {
> terminated = awaitTermination(Duration.ofDays(1L));
> } catch (InterruptedException e) {
> if (!interrupted) {
> interrupted = true;
> shutdownNow();
> if (isTerminated()) break;
> }
> }
> }
> if (interrupted) {
> Thread.currentThread().interrupt();
> }
> }
> } {code}
> My workaround
> {code:java}
> public void close() {
> if (client instanceof AutoCloseable) {
> try {
> client.shutdownNow();
> //((AutoCloseable)client).close();
> } catch (Exception e) {
> //ignore
> }
> } else if (client != null) {
> String name = client.toString();
> client = null;
> tryToShutdownSelector(name);
> }
> defaultAddress = null;
> super.close();
> } {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)