Return-Path: X-Original-To: apmail-cxf-dev-archive@www.apache.org Delivered-To: apmail-cxf-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DF50C17610 for ; Mon, 20 Apr 2015 11:42:09 +0000 (UTC) Received: (qmail 51865 invoked by uid 500); 20 Apr 2015 11:42:09 -0000 Delivered-To: apmail-cxf-dev-archive@cxf.apache.org Received: (qmail 51800 invoked by uid 500); 20 Apr 2015 11:42:09 -0000 Mailing-List: contact dev-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list dev@cxf.apache.org Received: (qmail 51788 invoked by uid 99); 20 Apr 2015 11:42:09 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 20 Apr 2015 11:42:09 +0000 X-ASF-Spam-Status: No, hits=1.3 required=5.0 tests=SPF_PASS,URI_HEX X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: message received from 54.191.145.13 which is an MX secondary for dev@cxf.apache.org) Received: from [54.191.145.13] (HELO mx1-us-west.apache.org) (54.191.145.13) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 20 Apr 2015 11:42:03 +0000 Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com [209.85.212.181]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with ESMTPS id 236712508B for ; Mon, 20 Apr 2015 11:41:40 +0000 (UTC) Received: by widdi4 with SMTP id di4so95387267wid.0 for ; Mon, 20 Apr 2015 04:41:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=g6hMX3eMpb7+/ydwi6MT+G645cMKKOnFq8Nx3SzEPuo=; b=hJoVOjJONG/hi1UOHtESYCPoVAt5szhfmEqlHmU3FrDAnPOBmwi891mgkJKguu/NFR xzfxxTUOcU4VA/qKRqDyCQTWSm/sxhWfW3Xz44i1gBGjnVBcJOvL/ERCal2sZp2RPN/f ESNseHv4rYLop96aiQLx7c7typkDMXiQN5gALFkyCt/nDJMPh5Fk8GzMFy1k8cWc019G zHOAD9jiX6Y0jbvW5HnMpMo2ZGOw6tFdKlwvpcbitq4FhCre+N0Tx3WOnfqMexhR+juA L4eC6y3cP6LHNlAN61uC3HUJ5VI/T2403lOLzG9wpC/ump0VcCcUzuEFUD7sJFyNeMGq 2yEw== X-Received: by 10.181.11.137 with SMTP id ei9mr23905932wid.48.1429530098931; Mon, 20 Apr 2015 04:41:38 -0700 (PDT) Received: from [10.36.226.2] ([80.169.137.63]) by mx.google.com with ESMTPSA id l3sm14879870wiv.18.2015.04.20.04.41.38 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Apr 2015 04:41:38 -0700 (PDT) Message-ID: <5534E5F1.2020108@gmail.com> Date: Mon, 20 Apr 2015 12:41:37 +0100 From: Sergey Beryozkin User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: dev@cxf.apache.org Subject: Re: NPE when calling ServiceUnavailableException.getRetryTime() References: <1429326257756-5756231.post@n5.nabble.com> <5534137B.6070001@gmail.com> <1429499839540-5756249.post@n5.nabble.com> In-Reply-To: <1429499839540-5756249.post@n5.nabble.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Hi You are right, thanks for spotting this issue and for your patch Cheers, Sergey On 20/04/15 04:17, iris ding wrote: > Hi Sergey, > > Let's take a look about the implementation details in > ServiceUnavailableException.getRetryTime(): > > public Date getRetryTime(Date requestTime) > { > RuntimeDelegate.HeaderDelegate dateDelegate; > String value = getResponse().getHeaderString("Retry-After"); > if (value == null) > return null; > > try > { > Long interval = Long.valueOf(Long.parseLong(value)); > return new Date(requestTime.getTime() + interval.longValue() * 1000L); > } > catch (NumberFormatException dateDelegate) > { > dateDelegate = > RuntimeDelegate.getInstance().createHeaderDelegate(Date.class); > } > return ((Date)dateDelegate.fromString(value)); > } > > If you pass a Date object to it, it will go into this: > > dateDelegate = > RuntimeDelegate.getInstance().createHeaderDelegate(Date.class); > > 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 > CacheControlHeaderProvider()); > 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: http://cxf.547215.n5.nabble.com/NPE-when-calling-ServiceUnavailableException-getRetryTime-tp5756231p5756249.html > Sent from the cxf-dev mailing list archive at Nabble.com. >