cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From iris ding <>
Subject Re: NPE when calling ServiceUnavailableException.getRetryTime()
Date Mon, 20 Apr 2015 03:17:19 GMT
Hi Sergey,

Let's take a look about the implementation details in

public Date getRetryTime(Date requestTime)
    RuntimeDelegate.HeaderDelegate dateDelegate;
    String value = getResponse().getHeaderString("Retry-After");
    if (value == null)
      return null;

      Long interval = Long.valueOf(Long.parseLong(value));
      return new Date(requestTime.getTime() + interval.longValue() * 1000L);
    catch (NumberFormatException dateDelegate)
      dateDelegate =
    return ((Date)dateDelegate.fromString(value));

If you pass a Date object to it, it will go into this:

dateDelegate =

org.apache.cxf.jaxrs.impl.RuntimeDelegateImpl is CXF implementation for
RuntimeDelegate, In this class, you can see it does not register a provider
to handle Date type:

public RuntimeDelegateImpl() {
        headerProviders.put(MediaType.class, new MediaTypeHeaderProvider());
        headerProviders.put(CacheControl.class, new
        headerProviders.put(EntityTag.class, new EntityTagHeaderProvider());
        headerProviders.put(Cookie.class, new CookieHeaderProvider());
        headerProviders.put(NewCookie.class, new NewCookieHeaderProvider());

So the NPE occurs and the API call fails.

The fix I proposed here is to add a DateHeaderProvider to handle Date type.

I do not think NPE here is correct. If so, does it mean we do not support
this API( ServiceUnavailableException.getRetryTime())  call at all?

Thanks & Best Regards,

Iris Ding

View this message in context:
Sent from the cxf-dev mailing list archive at

View raw message