Using java11 Http Client as below,
HttpClient httpClient = HttpClient.newBuilder()
.version(HttpClient.Version.HTTP_1_1)
.followRedirects(HttpClient.Redirect.NORMAL)
.connectTimeout(Duration.ofSeconds(Long.valueOf(matchMakerHttpConnectionTimeout)))
.build();
HttpRequest httpRequest = HttpRequest.newBuilder()
.POST(requestBody)
.uri(URI.create(baseurl))
.timeout(Duration.ofSeconds(requestTimeOut))
.setHeader("Content-Type", "application/json; charset=UTF-8")
.setHeader("Authorization", "Bearer " + accessToken).build();
LOGGER.info("Base url : {} with request body : {}", baseurl, request);
HttpResponse<String> response = httpClient.send(httpRequest,BodyHandlers.ofString());
LOGGER.info("Response body from delete CM API is : {}",response.body());
We see not receiving response from external api call happened via java 11 HttpClient.send()
as above. Also not getting timeout as well. but timeouts are configured in HttpClient and HttpRequest.Because the logger message after called httpclient.send() is not printed anywhere after HttpClient call happens.
Am i missing anything here? why we were not getting timeout if no response received from external call for long time?
Also why am i getting this stack trace printed more in thread dump?
"pool-3-thread-2" #57 prio=5 os_prio=0 cpu=7204.26ms elapsed=16809.99s tid=0x000056033ed08800 nid=0x59 waiting on condition [0x00007f263fc89000]
java.lang.Thread.State: WAITING (parking)
at jdk.internal.misc.Unsafe.park(java.base@11.0.5/Native Method)
- parking to wait for <0x00000000c54cb950> (a java.util.concurrent.CompletableFuture$Signaller)
at java.util.concurrent.locks.LockSupport.park(java.base@11.0.5/LockSupport.java:194)
at java.util.concurrent.CompletableFuture$Signaller.block(java.base@11.0.5/CompletableFuture.java:1796)
at java.util.concurrent.ForkJoinPool.managedBlock(java.base@11.0.5/ForkJoinPool.java:3128)
at java.util.concurrent.CompletableFuture.waitingGet(java.base@11.0.5/CompletableFuture.java:1823)
at java.util.concurrent.CompletableFuture.get(java.base@11.0.5/CompletableFuture.java:1998)
at jdk.internal.net.http.HttpClientImpl.send(java.net.http@11.0.5/HttpClientImpl.java:541)
at jdk.internal.net.http.HttpClientFacade.send(java.net.http@11.0.5/HttpClientFacade.java:119)
at com.comcast.bo.rlcm.cmdp.helper.SampleServiceHelper.invokeAPI(SampleServiceHelper.java:273)
at com.comcast.bo.rlcm.cmdp.helper.SampleServiceHelper.lambda$invokeCmAPI$7(SampleServiceHelper.java:220)
at com.comcast.bo.rlcm.cmdp.helper.SampleServiceHelper$$Lambda$1778/0x0000000100d66440.accept(Unknown Source)
at java.util.HashMap.forEach(java.base@11.0.5/HashMap.java:1336)
at com.comcast.bo.rlcm.cmdp.helper.SampleClassA.invokeHttpClientForExternalApi(SampleService.java:201)
at com.comcast.bo.rlcm.cmdp.service.SampleService.lambda$processCm$4(SampleService.java:310)
at com.comcast.bo.rlcm.cmdp.service.SampleService$$Lambda$1302/0x0000000100c6b840.accept(Unknown Source)
at java.util.concurrent.ConcurrentHashMap.forEach(java.base@11.0.5/ConcurrentHashMap.java:1603)
at com.comcast.bo.rlcm.cmdp.service.SampleService.processCm(SampleService.java:224)
at com.comcast.bo.rlcm.cmdp.service.SampleService$$FastClassBySpringCGLIB$$f43afa24.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:687)
at com.comcast.bo.rlcm.cmdp.service.SampleService$$EnhancerBySpringCGLIB$$33bd9b1c.processCm(<generated>)
at com.comcast.bo.rlcm.cmdp.service.SampleService2.processCM(SampleService2.java:99)
at com.comcast.bo.rlcm.cmdp.cmjob.processor.SampleProcessor.run(SampleProcessor.java:42)
at java.util.concurrent.Executors$RunnableAdapter.call(java.base@11.0.5/Executors.java:515)
at java.util.concurrent.FutureTask.run(java.base@11.0.5/FutureTask.java:264)
at java.util.concurrent.ThreadPoolExecutor.runWorker(java.base@11.0.5/ThreadPoolExecutor.java:1128)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(java.base@11.0.5/ThreadPoolExecutor.java:628)
at java.lang.Thread.run(java.base@11.0.5/Thread.java:834)