www-authenticate请求头导致JettyClientHttpConnector调用阻塞异常
问题:Spring Boot 3迁移后Jetty WebClient处理WWW-Authenticate头时阻塞
环境
- Spring Boot 3.3.4
- Spring Web 6.1.1
原正常运行环境
- Spring Boot 2.7.18
- Spring Web 5.3.31
问题背景
从Spring Boot 2.7.18迁移到3.3.4后,使用配置了JettyClientHttpConnector的WebClient调用返回WWW-Authenticate响应头的接口时,出现无限阻塞,无法正常获取响应。该场景在Spring Boot 2中可正常运行,已尝试最基础的连接器配置,只要接口返回该响应头就触发异常。
示例代码
仅配置WebClient使用JettyClientHttpConnector测试,代码如下:
WebClient client = WebClient.builder() .baseUrl("your-url-with-www-authenticate-header-in-response") .clientConnector(new JettyClientHttpConnector()) .build();
异常信息
调用接口后阻塞,超时后抛出如下错误:
onFillableFail SslConnection@10ac4a81::SocketChannelEndPoint@4d09e077[{l=null,r=null,CLOSED,fill=-,flush=-,to=7/30000}{io=1/1,kio=-1,kro=-1}]->[SslConnection@10ac4a81{NOT_HANDSHAKING,eio=-1/-1,di=-1,fill=INTERESTED,flush=IDLE}~>{l=null,r=null,CLOSED,fill=FI,flush=-,to=30027/30000}=>HttpConnectionOverHTTP@46f46e11(l:null <-> r:null,closed=true)=>HttpChannelOverHTTP@11d2c7ca(exchange=null)[send=HttpSenderOverHTTP@4f015fae(req=QUEUED,failure=null)[HttpGenerator@3d8bec8d{s=START}],recv=HttpReceiverOverHTTP@69f1010a(ex=null,rsp=IDLE,failure=null)[HttpParser{s=START,0 of -1}]]] java.nio.channels.ClosedChannelException: null at org.eclipse.jetty.io.FillInterest.onClose(FillInterest.java:147) at org.eclipse.jetty.io.AbstractEndPoint.onClose(AbstractEndPoint.java:336) at org.eclipse.jetty.io.SelectableChannelEndPoint.onClose(SelectableChannelEndPoint.java:165) at org.eclipse.jetty.io.AbstractEndPoint.onClose(AbstractEndPoint.java:326) at org.eclipse.jetty.io.AbstractEndPoint.doOnClose(AbstractEndPoint.java:253) at org.eclipse.jetty.io.AbstractEndPoint.close(AbstractEndPoint.java:217) at org.eclipse.jetty.io.AbstractEndPoint.close(AbstractEndPoint.java:200) at org.eclipse.jetty.io.ssl.SslConnection$SslEndPoint.disconnect(SslConnection.java:1399) at org.eclipse.jetty.io.ssl.SslConnection$SslEndPoint.doShutdownOutput(SslConnection.java:1381) at org.eclipse.jetty.io.ssl.SslConnection$SslEndPoint.doClose(SslConnection.java:1449) at org.eclipse.jetty.io.AbstractEndPoint.doOnClose(AbstractEndPoint.java:248) at org.eclipse.jetty.io.AbstractEndPoint.close(AbstractEndPoint.java:217) at org.eclipse.jetty.io.AbstractEndPoint.close(AbstractEndPoint.java:200) at org.eclipse.jetty.client.transport.internal.HttpConnectionOverHTTP.close(HttpConnectionOverHTTP.java:298) at org.eclipse.jetty.client.transport.internal.HttpConnectionOverHTTP.onIdleExpired(HttpConnectionOverHTTP.java:237) at org.eclipse.jetty.io.ssl.SslConnection.onIdleExpired(SslConnection.java:371) at org.eclipse.jetty.io.AbstractEndPoint.onIdleExpired(AbstractEndPoint.java:389) at org.eclipse.jetty.io.IdleTimeout.checkIdleTimeout(IdleTimeout.java:172) at org.eclipse.jetty.io.IdleTimeout.idleCheck(IdleTimeout.java:113)
调试日志
请求会不断重试直至报错,始终无法正常结束,相关调试日志如下:
[DEBUG] [ o.e.j.u.t.ReservedThreadExecutor: 348 ] waiting for task [DEBUG] [ com.zaxxer.hikari.pool.HikariPool: 405 ] HikariPool-1 - Pool stats (total=10, active=0, idle=10, waiting=0) [DEBUG] [ com.zaxxer.hikari.pool.HikariPool: 510 ] HikariPool-1 - Fill pool skipped, pool has sufficient level or currently being filled. [DEBUG] [ o.e.j.util.thread.QueuedThreadPool: 1015 ] Evict check, period=60000ms QueuedThreadPool[HttpClient@7218bb00]@42681628{STARTED,8<=12<=200,i=3,r=-1,t=-67ms,q=0}[ReservedThreadExecutor@7457d199{capacity=16,threads=ThreadIdPool@397ce9d8{capacity=16}}] [DEBUG] [ o.e.j.util.thread.QueuedThreadPool: 1033 ] Evict skipped, threshold=59932ms in the future QueuedThreadPool[HttpClient@7218bb00]@42681628{STARTED,8<=12<=200,i=3,r=-1,t=-67ms,q=0}[ReservedThreadExecutor@7457d199{capacity=16,threads=ThreadIdPool@397ce9d8{capacity=16}}] [DEBUG] [ o.e.j.u.t.ReservedThreadExecutor: 348 ] waiting for task [DEBUG] [ o.e.j.util.thread.QueuedThreadPool: 1015 ] Evict check, period=60000ms QueuedThreadPool[HttpClient@7218bb00]@42681628{STARTED,8<=12<=200,i=3,r=-1,t=-74ms,q=0}[ReservedThreadExecutor@7457d199{capacity=16,threads=ThreadIdPool@397ce9d8{capacity=16}}] [DEBUG] [ o.e.j.util.thread.QueuedThreadPool: 1033 ] Evict skipped, threshold=59925ms in the future QueuedThreadPool[HttpClient@7218bb00]@42681628{STARTED,8<=12<=200,i=3,r=-1,t=-75ms,q=0}[ReservedThreadExecutor@7457d199{capacity=16,threads=ThreadIdPool@397ce9d8{capacity=16}}] [DEBUG] [ com.zaxxer.hikari.pool.PoolBase: 133 ] HikariPool-1 - Closing connection oracle.jdbc.driver.T4CConnection@24c9581b: (connection has passed maxLifetime) [DEBUG] [ com.zaxxer.hikari.pool.HikariPool: 728 ] HikariPool-1 - Added connection oracle.jdbc.driver.T4CConnection@c485e55 [DEBUG] [ com.zaxxer.hikari.pool.HikariPool: 405 ] HikariPool-1 - Connection not added, stats (total=10, active=0, idle=10, waiting=0)
完全相同的代码在Spring Boot 2环境中可正常处理请求,求解决该问题。
内容的提问来源于stack exchange,提问作者Ramss Martnez Martnez Canocles
相关产品推荐
相关产品推荐

