java.util.concurrent.TimeoutException:状态200后为null OK



我目前正在开发一个Java 11 Spring引导应用程序。在CompletableFuture中,我正在向Web服务发送大量REST请求。其中只有一个(似乎是随机的(会导致TimeoutException,尽管它后面是日志记录中的成功状态200 OK接收响应。以下(匿名(日志条目:

[Thread-6] INFO  n.d.b.a.b.i.RESTInterceptor - Request              : <url value>?code=abcd&begindatum=2018-10-01&einddatum=2018-10-02
[http-nio-8080-exec-1] ERROR o.a.c.c.C.[.[.[.[dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] in context with path [/xxx] threw exception [Request processing failed; nested exception is java.util.concurrent.CompletionException: java.util.concurrent.TimeoutException] with root cause
java.util.concurrent.TimeoutException: null
at java.base/java.util.concurrent.CompletableFuture$Timeout.run(CompletableFuture.java:2792)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
[Thread-6] DEBUG n.d.b.a.b.i.RESTInterceptor - Response statuscode  : 200 OK
[Thread-6] DEBUG n.d.b.a.b.i.RESTInterceptor - Response headers     : [X-Application-Context:"yyyy", Cache-Control:"no-cache, no-store, max-age=0, must-revalidate", Pragma:"no-cache", Expires:"0", Server:"CD", X-Powered-By:"Unknown", Content-Type:"application/json;charset=UTF-8", Date:"Tue, 06 Apr 2021 15:23:16 GMT", Connection:"close", X-Frame-Options:"SAMEORIGIN", X-XSS-Protection:"1;mode=block", X-Content-Type-Options:"nosniff"]
[Thread-6] INFO  n.d.b.a.b.i.RESTInterceptor - Response             : [{"begindatum":"1993-01-01","id":"aaaaa","vanInstellingserkenningId":"bbbbb","naarInstellingserkenningId":"ccccc","soort":"HIERARCHISCH","naarInstellingserkenning":{"id":"ddddd","type":"ERKENDE_ONDERWIJSINSTELLING","code":"abcd"},"vanInstellingserkenning":{"id":"kkkk","type":"BEVOEGD_GEZAG","code":"12345"}}]

有没有人有同样的经历?我看不出成功完成的请求和"失败"的请求有什么区别。

在对问题进行更深入的分析后,我终于发现TimeoutException是从应用程序中其他地方的另一个Future处理中抛出的。我感到困惑的是,对未来的处理(异步任务,每个任务都在自己的线程中(并不像日志文件中那样。日志片段中显示的TimeoutException未在显示的请求-响应交互中引发。很抱歉造成混淆,但这个答案可能会对其他人有所帮助。

最新更新