You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Andriy Redko (Jira)" <ji...@apache.org> on 2026/04/10 17:01:00 UTC

[jira] [Resolved] (CXF-9210) JAX-RS Client Fails When CacheControlFeature is used but Server Doesn't return Cache-Control Header

     [ https://issues.apache.org/jira/browse/CXF-9210?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andriy Redko resolved CXF-9210.
-------------------------------
    Resolution: Fixed

> JAX-RS Client Fails When CacheControlFeature is used but Server Doesn't return Cache-Control Header
> ---------------------------------------------------------------------------------------------------
>
>                 Key: CXF-9210
>                 URL: https://issues.apache.org/jira/browse/CXF-9210
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 4.2.0, 4.1.5, 3.6.10
>            Reporter: Corey Bodendein
>            Assignee: Freeman Yue Fang
>            Priority: Major
>             Fix For: 4.2.1, 3.6.11, 4.1.6
>
>
> When you add the {{org.apache.cxf.jaxrs.client.cache.CXFCacheControlFeature}} to a JAX-RS client and use it with a server that does not return the {{Cache-Control}} header, reading the whole response fails with a partial stacktrace like:
> {noformat}
> javax.ws.rs.client.ResponseProcessingException: Problem with reading the data, class java.lang.String, ContentType: text/plain.
> 	at org.apache.cxf.jaxrs.impl.ResponseImpl.reportMessageHandlerProblem(ResponseImpl.java:553)
> 	at org.apache.cxf.jaxrs.impl.ResponseImpl.doReadEntity(ResponseImpl.java:495)
> 	at org.apache.cxf.jaxrs.impl.ResponseImpl.readEntity(ResponseImpl.java:410)
> 	at org.apache.cxf.jaxrs.impl.ResponseImpl.readEntity(ResponseImpl.java:400)
> ...
> Caused by: java.lang.IllegalArgumentException
> 	at org.apache.cxf.jaxrs.impl.CacheControlHeaderProvider.getTokens(CacheControlHeaderProvider.java:119)
> 	at org.apache.cxf.jaxrs.impl.CacheControlHeaderProvider.fromString(CacheControlHeaderProvider.java:71)
> 	at org.apache.cxf.jaxrs.impl.CacheControlHeaderProvider.fromString(CacheControlHeaderProvider.java:37)
> 	at javax.ws.rs.core.CacheControl.valueOf(CacheControl.java:88)
> 	at org.apache.cxf.jaxrs.client.cache.CacheControlClientReaderInterceptor.aroundReadFrom(CacheControlClientReaderInterceptor.java:91)
> 	at org.apache.cxf.jaxrs.utils.JAXRSUtils.readFromMessageBodyReader(JAXRSUtils.java:1603)
> 	at org.apache.cxf.jaxrs.impl.ResponseImpl.doReadEntity(ResponseImpl.java:474)
> {noformat}
> This looks to be because on these two lines, https://github.com/apache/cxf/blob/cxf-3.6.10/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/cache/CacheControlClientReaderInterceptor.java#L90-L91 :
> {code:java}
> final String cacheControlHeader = responseHeaders.getFirst(HttpHeaders.CACHE_CONTROL);
> final CacheControl cacheControl = CacheControl.valueOf(cacheControlHeader);
> {code}
> If the server does not have the {{Cache-Control}} header, {{cacheControlHeader}} is {{null}}, and {{CacheControl.valueOf(null)}} throws a {{IllegalArgumentException}}.
> {{org.apache.cxf.jaxrs.client.cache.CacheControlClientReaderInterceptor#aroundReadFrom}} should return early in that case to prevent errors reading the response.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)