Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 02A83200CE6 for ; Thu, 17 Aug 2017 00:37:10 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 00D37169CB1; Wed, 16 Aug 2017 22:37:10 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id C4A7A169CB0 for ; Thu, 17 Aug 2017 00:37:08 +0200 (CEST) Received: (qmail 93610 invoked by uid 500); 16 Aug 2017 22:37:07 -0000 Mailing-List: contact users-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@cxf.apache.org Delivered-To: mailing list users@cxf.apache.org Received: (qmail 93598 invoked by uid 99); 16 Aug 2017 22:37:07 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Aug 2017 22:37:07 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 07002180819 for ; Wed, 16 Aug 2017 22:37:07 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -1.588 X-Spam-Level: X-Spam-Status: No, score=-1.588 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-2.8, SPF_PASS=-0.001, URI_HEX=1.313] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id HBP01gSfAGRa for ; Wed, 16 Aug 2017 22:37:05 +0000 (UTC) Received: from mail-wr0-f176.google.com (mail-wr0-f176.google.com [209.85.128.176]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id A8E5B5FB96 for ; Wed, 16 Aug 2017 22:37:04 +0000 (UTC) Received: by mail-wr0-f176.google.com with SMTP id b65so28471403wrd.0 for ; Wed, 16 Aug 2017 15:37:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=TCRt1r073STrsStvpzC7UBxr8pS0jkK/Pu3K4vU9Zcs=; b=dD0Ud9e0gL7j6R3HKayYf5LFId4nM1I1Pbl3QB7sbdZJdLp9CbStNOXPgQ2RJQ2nQ3 Xg9sYjjqbzVHw3LDSkRwHNp1wVj435CzVrgnEG6+WRAQqkGyyj4gAztE5tQIiT+CjkBS mKbvA4UGJBwIxBweXu6Gyz/8+1v9H0K/GfxrKMfW21nqFs1tGynShvMhD04BTfEoXXuf aMWcnUzjGWPFFu9WuHfw9xEee5YbCkWZmmzZIAwhH+hwkwIupH1KNWrda1R6o9jbhjqR RbJkbGnCRE0+SNsexr1lxpa9SgAUKEMvR/eewv/BOHVHaq2kJU6hyXnwizqj85sknOll uoFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=TCRt1r073STrsStvpzC7UBxr8pS0jkK/Pu3K4vU9Zcs=; b=g6vekMWE9Y0knSV1ANqDiqYdfLm0gCYtTvCpj/cXNYPTfelf2GcpgYc5ZVkYS7M1rj F37M7v1dHTq4h3fAonfLNu7R03Ca5K5qvIc1oa2pSYrrRFes3CCKFGByV4v8WDqY2Zrh 0szlnSbJPU41jra0U+mfHO2TG9XOWcKXUCDbi2eKpsTVZuh7ZS04CHImd1tzRk2AEUkC S8H5vSl2uMw/TL91luPAvmqvK8wAJYIk62meWv/3o1sz+wN6jxg1IhLn4iewA9TmzCmZ CwQfdbsQTtXg8058k14CByTjLQTmhFlrZRt+jGWWrzkqzF7d/VViVlg12wxTLQu2VNBq W4aw== X-Gm-Message-State: AHYfb5j+mpADtFY3coId6LVejM9oe1zAxLhKDjEN1BHCK8nvqDPKZhxW GpeAeRl4XulFCjqXkhE= X-Received: by 10.80.208.217 with SMTP id g25mr3105847edf.229.1502923023393; Wed, 16 Aug 2017 15:37:03 -0700 (PDT) Received: from [192.168.2.5] ([46.7.75.77]) by smtp.googlemail.com with ESMTPSA id a33sm1177255edd.67.2017.08.16.15.37.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Aug 2017 15:37:02 -0700 (PDT) Subject: Re: Closing of WebClient and Response objects To: users@cxf.apache.org References: <6547E394-5FD5-4A2D-944F-8A9B8AFC2388@gmail.com> <53FC567A.70608@gmail.com> <1502835642799-5782716.post@n5.nabble.com> <7619ba54-e953-7c00-4208-ce79b6e2de25@gmail.com> <97ce1929-5703-dd09-2e0f-a1251ff87aee@gmail.com> From: Sergey Beryozkin Message-ID: <06ba0228-e691-f199-953e-60dcff7324ca@gmail.com> Date: Wed, 16 Aug 2017 23:37:01 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit archived-at: Wed, 16 Aug 2017 22:37:10 -0000 Yes, I see "response.stream.auto.close" does not work if you do something like webCliemt.get(Book.class) but does work if you do webCliemt.get().readEntity(Book.class) I recall now I might've implemented this property while working on JAX-RS 2.0 impl of Response which talks about this auto-closing in its docs, while the usage of this property in a case where response is read implicitly was not taken care of So if you'd do to continue doing the auto-closing just follow webCliemt.get().readEntity(Book.class) pattern in meantime I'll have a look at this property working in a webCliemt.get(Book.class) Sergey On 16/08/17 23:04, sbalustar wrote: > Sergey , > > In CXF 2.7.7, in readBody method, there is no call for readEntity, thats > why it is not throwing any exception . But in 3.1.8 , first readEntity > method is called and later getEntity method is called. Seems like it is > Bug in AbstractClient.java in 3.1.8 version. What do you say? > > On Wed, Aug 16, 2017 at 2:51 PM, Balakrishna Sudabathula < > bsudabathula@gmail.com> wrote: > >> readBody method code () >> >> protected T readBody(Response r, Message outMessage, Class cls, >> >> >> Type type, Annotation[] anns) { >> >> >> >> if (cls == Response.class) { >> >> return cls.cast(r); >> >> } >> >> >> >> int status = r.getStatus(); >> >> if ((status < 200 || status == 204) && r.getLength() <= 0 || >> status >= 300) { >> >> return null; >> >> } >> >> return ((ResponseImpl)r).doReadEntity(cls, type, anns); >> >> >> } >> >> On Wed, Aug 16, 2017 at 2:48 PM, Balakrishna Sudabathula < >> bsudabathula@gmail.com> wrote: >> >>> Please find the attachement. In WebClient handle handleResponse () method >>> there is method call readBody (), in that method readEntity method is >>> called. After that there is another method call JAXRSUtils.fromRespons >>> which is calling getEntity method >>> >>> >>> >>> On Wed, Aug 16, 2017 at 2:29 PM, Sergey Beryozkin [via CXF] < >>> ml+s547215n5782761h25@n5.nabble.com> wrote: >>> >>>> So where is readEntity is called from ? >>>> On 16/08/17 22:26, sbalustar wrote: >>>> >>>>> In CXF 3.1.8 >>>>> >>>>> There is a call in readEntity menthod autoClose(), but in cxf 2.7.7 >>>> there >>>>> is no such method call. >>>>> >>>>> protected void autoClose(Class cls, boolean exception) { >>>>> >>>>> if (!entityBufferred && cls != InputStream.class >>>>> >>>>> && (exception || MessageUtils.isTrue(outMessage >>>>> .getContextualProperty("response.stream.auto.close")))) { >>>>> >>>>> close(); >>>>> >>>>> } >>>>> >>>>> } >>>>> >>>>> >>>>> If the auto close is set to true , then it is calling close method , >>>> and >>>>> changing the entityClosed value to true. >>>>> >>>>> >>>>> >>>>> On Wed, Aug 16, 2017 at 2:18 PM, Balakrishna Sudabathula < >>>>> [hidden email] > >>>> wrote: >>>>> >>>>>> Why because IN CXF 3.1.8 , The Code in the ResponseImpl class is like >>>> below >>>>>> >>>>>> >>>>>> public Object getEntity() { >>>>>> return InjectionUtils.getEntity(getActualEntity()); >>>>>> } >>>>>> >>>>>> >>>>>> public Object getActualEntity() { >>>>>> checkEntityIsClosed(); >>>>>> return lastEntity != null ? lastEntity : entity; >>>>>> } >>>>>> >>>>>> private void checkEntityIsClosed() { >>>>>> >>>>>> if (entityClosed) { >>>>>> >>>>>> throw new IllegalStateException("Entity is not >>>> available"); >>>>>> >>>>>> } >>>>>> >>>>>> } >>>>>> >>>>>> >>>>>> public void close() throws ProcessingException { >>>>>> >>>>>> if (!entityClosed) { >>>>>> >>>>>> if (!entityBufferred && entity instanceof InputStream) { >>>>>> >>>>>> try { >>>>>> >>>>>> ((InputStream)entity).close(); >>>>>> >>>>>> } catch (IOException ex) { >>>>>> >>>>>> throw new ResponseProcessingException(this, >>>> ex); >>>>>> >>>>>> } >>>>>> >>>>>> } >>>>>> >>>>>> entity = null; >>>>>> >>>>>> entityClosed = true; >>>>>> >>>>>> } >>>>>> >>>>>> >>>>>> >>>>>> } >>>>>> In the readEntity method, there is a call to close() method which the >>>>>> entityClosed variable value is set to true. When calling the >>>> getEntity() >>>>>> method , there is a another method call checkEntityIsClosed is >>>> throwing the >>>>>> exception because the entityClosed is set to true in readEntity. >>>>>> >>>>>> >>>>>> But In CXF 2.7.7, there is no method call in the getEntity() method >>>> , >>>>>> simply it returns the entity >>>>>> >>>>>> public Object getEntity() { >>>>>> return lastEntity != null ? lastEntity : entity; >>>>>> } >>>>>> >>>>>> >>>>>> On Wed, Aug 16, 2017 at 1:58 PM, Sergey Beryozkin [via CXF] < >>>>>> [hidden email] >>>> > wrote: >>>>>> >>>>>>> Hi, that will need to be measured for a concrete flow. >>>>>>> I'm still not sure why you are seeing the failure with the auto >>>> close >>>>>>> being on - it only takes effect after the entity has been >>>> consumed... >>>>>>> >>>>>>> Sergey >>>>>>> On 16/08/17 19:03, sbalustar wrote: >>>>>>> >>>>>>>> Hi Sergey, >>>>>>>> >>>>>>>> At runtime, in Debug mode Changed the >>>>>>> response.stream.auto.close=false. >>>>>>>> Later on , i am not facing the Entity Not available Exception. >>>>>>>> >>>>>>>> Is there any impact on the performance when we disabled the >>>> flag? >>>>>>>> >>>>>>>> On Wed, Aug 16, 2017 at 3:32 AM, Sergey Beryozkin [via CXF] < >>>>>>>> [hidden email] >>> pe=node&node=5782757&i=0>> >>>>>>> wrote: >>>>>>>> >>>>>>>>> Hi >>>>>>>>> >>>>>>>>> I don't quite understand what the issue is, does it happen when >>>> you >>>>>>>>> enable "response.stream.auto.close" ? If yes - what happens if you >>>> do >>>>>>>>> not enable this property ? >>>>>>>>> >>>>>>>>> CXF does not auto-close the input stream by default given of the >>>> few >>>>>>>>> well-known side-effects. >>>>>>>>> >>>>>>>>> Given you have already tried to debug - it is better to set a >>>>>>> breakpoint >>>>>>>>> inside org.apache.cxf.jaxrs.impl.ResponseImpl - there you will >>>> see >>>>>>> why >>>>>>>>> InputStream is not available in your case >>>>>>>>> >>>>>>>>> Cheers, Sergey >>>>>>>>> >>>>>>>>> On 15/08/17 23:20, sbalustar wrote: >>>>>>>>> >>>>>>>>>> HI sergey, We are upgrading CXF version 2.7.7 to 3.1.8 and facing >>>> the >>>>>>>>> below >>>>>>>>>> issue. >>>>>>>>>> >>>>>>>>>> AUDIT:2017-08-15 11:31:11.047:localhost-startStop-1:"Caused by >>>>>>>>>> javax.ws.rs.ProcessingException: java.lang.IllegalStateException: >>>> >>>>>>>>> Entity is >>>>>>>>>> not available >>>>>>>>>> at >>>>>>>>>> org.apache.cxf.jaxrs.client.WebClient.handleResponse(WebClient.java:1141) >>>> >>>>>>> >>>>>>>>> >>>>>>>>>> at org.apache.cxf.jaxrs.client.We >>>> bClient.doResponse(WebClient.java:1110) >>>>>>> >>>>>>>>> >>>>>>>>>> at >>>>>>>>>> org.apache.cxf.jaxrs.client.WebClient.doChainedInvocation(WebClient.java:1035) >>>> >>>>>>> >>>>>>>>> >>>>>>>>>> at org.apache.cxf.jaxrs.client.We >>>> bClient.doInvoke(WebClient.java:892) >>>>>>> >>>>>>>>> >>>>>>>>>> at org.apache.cxf.jaxrs.client.We >>>> bClient.doInvoke(WebClient.java:863) >>>>>>> >>>>>>>>> >>>>>>>>>> at org.apache.cxf.jaxrs.client.We >>>> bClient.invoke(WebClient.java:413) >>>>>>> >>>>>>>>> >>>>>>>>>> at >>>>>>>>>> com.walmart.platform.soa.client.RestClient.invoke(RestClient.java:261) >>>> >>>>>>> >>>>>>>>>> ... 78 more >>>>>>>>>> >>>>>>>>>> I have gone through this ticket >>>>>>>>>> https://issues.apache.org/jira/browse/CXF-5144 which you >>>> mentioned >>>>>>> that >>>>>>>>> Set >>>>>>>>>> this property: "response.stream.auto.close" to true. This is done >>>>>>> even >>>>>>>>>> though we are getting the same issue. >>>>>>>>>> >>>>>>>>>> When i debug the code, in WebClient.invoke method this exception >>>> is >>>>>>>>> occured. >>>>>>>>>> >>>>>>>>>> protected Response handleResponse(Message outMessage, >>>> Class >>>>>>>>>> responseClass, Type genericType) { >>>>>>>>>> try { >>>>>>>>>> ResponseBuilder rb = >>>> setResponseBuilder(outMessage, >>>>>>>>>> outMessage.getExchange()); >>>>>>>>>> Response currentResponse = rb.clone().build(); >>>>>>>>>> ((ResponseImpl)currentResponse).setOutMessage(outMessage); >>>> >>>>>>> >>>>>>>>>> >>>>>>>>>> Object entity = readBody(currentResponse, >>>> outMessage, >>>>>>>>>> responseClass, genericType, >>>>>>>>>> new Annotation[]{}); >>>>>>>>>> >>>>>>>>>> if (entity == null) { >>>>>>>>>> int status = currentResponse.getStatus(); >>>>>>>>>> if (status >= 400) { >>>>>>>>>> entity = currentResponse.getEntity(); >>>>>>>>>> } >>>>>>>>>> } >>>>>>>>>> rb = JAXRSUtils.fromResponse(currentResponse); >>>>>>>>>> >>>>>>>>>> rb.entity(entity instanceof Response >>>>>>>>>> ? ((Response)entity).getEntity() : >>>> entity); >>>>>>>>>> >>>>>>>>>> Response r = rb.build(); >>>>>>>>>> getState().setResponse(r); >>>>>>>>>> ((ResponseImpl)r).setOutMessage(outMessage); >>>>>>>>>> return r; >>>>>>>>>> } catch (Throwable ex) { >>>>>>>>>> throw (ex instanceof ProcessingException) ? >>>>>>>>>> (ProcessingException)ex >>>>>>>>>> : new >>>>>>>>>> ProcessingException(ex); >>>>>>>>>> } finally { >>>>>>>>>> >>>>>>>>>> ClientProviderFactory.getInstance(outMessage).clearThreadLocalProxies(); >>>> >>>>>>> >>>>>>>>> >>>>>>>>>> } >>>>>>>>>> } >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> public static ResponseBuilder fromResponse(Response >>>> response) { >>>>>>>>>> ResponseBuilder rb = toResponseBuilder(response.getStatus()); >>>> >>>>>>> >>>>>>>>>> * rb.entity(response.getEntity()); >>>>>>>>>> * for (Map.Entry> entry : >>>>>>>>>> response.getMetadata().entrySet()) { >>>>>>>>>> List values = entry.getValue(); >>>>>>>>>> for (Object value : values) { >>>>>>>>>> rb.header(entry.getKey(), value); >>>>>>>>>> } >>>>>>>>>> } >>>>>>>>>> return rb; >>>>>>>>>> } >>>>>>>>>> >>>>>>>>>> * rb.entity(response.getEntity()); >>>>>>>>>> * seems like , entity is null in ResponseBuilder rb from the >>>>>>>>> fromResponse >>>>>>>>>> method. >>>>>>>>>> >>>>>>>>>> Please let me know, what could be the solution to fix this issue? >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> -- >>>>>>>>>> View this message in context: http://cxf.547215.n5.nabble. >>>>>>>>> com/Closing-of-WebClient-and-Response-objects-tp5748134p5782716.html >>>> >>>>>>>>>> Sent from the cxf-user mailing list archive at Nabble.com. >>>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> -- >>>>>>>>> Sergey Beryozkin >>>>>>>>> >>>>>>>>> Talend Community Coders >>>>>>>>> http://coders.talend.com/ >>>>>>>>> >>>>>>>>> >>>>>>>>> ------------------------------ >>>>>>>>> If you reply to this email, your message will be added to the >>>>>>> discussion >>>>>>>>> below: >>>>>>>>> http://cxf.547215.n5.nabble.com/Closing-of-WebClient-and-Res >>>>>>> ponse-objects- >>>>>>>>> tp5748134p5782725.html >>>>>>>>> To unsubscribe from Closing of WebClient and Response objects, >>>> click >>>>>>> here >>>>>>>>> < >>>>>>>>> . >>>>>>>>> NAML >>>>>>>>> >>>>>> cro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base= >>>>>>> nabble.naml.namespaces.BasicNamespace-nabble.view.web. >>>>>>> template.NabbleNamespace-nabble.view.web.template.NodeNamesp >>>>>>> ace&breadcrumbs=notify_subscribers%21nabble%3Aemail. >>>>>>> naml-instant_emails%21nabble%3Aemail.naml-send_instant_ >>>>>>> email%21nabble%3Aemail.naml> >>>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> -- >>>>>>>> View this message in context: http://cxf.547215.n5.nabble.co >>>>>>> m/Closing-of-WebClient-and-Response-objects-tp5748134p5782748.html >>>>>>>> Sent from the cxf-user mailing list archive at Nabble.com. >>>>>>>> >>>>>>> >>>>>>> >>>>>>> ------------------------------ >>>>>>> If you reply to this email, your message will be added to the >>>> discussion >>>>>>> below: >>>>>>> http://cxf.547215.n5.nabble.com/Closing-of-WebClient-and-Res >>>>>>> ponse-objects-tp5748134p5782757.html >>>>>>> To unsubscribe from Closing of WebClient and Response objects, click >>>> here >>>>>>> < >>>>>>> . >>>>>>> NAML >>>>>>> >>> cro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base= >>>> nabble.naml.namespaces.BasicNamespace-nabble.view.web.templa >>>> te.NabbleNamespace-nabble.view.web.template.NodeNamespac >>>> e&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml- >>>> instant_emails%21nabble%3Aemail.naml-send_instant_email% >>>> 21nabble%3Aemail.naml> >>>>>>> >>>>>> >>>>>> >>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> View this message in context: http://cxf.547215.n5.nabble.co >>>> m/Closing-of-WebClient-and-Response-objects-tp5748134p5782759.html >>>>> Sent from the cxf-user mailing list archive at Nabble.com. >>>>> >>>> >>>> >>>> -- >>>> Sergey Beryozkin >>>> >>>> Talend Community Coders >>>> http://coders.talend.com/ >>>> >>>> >>>> ------------------------------ >>>> If you reply to this email, your message will be added to the discussion >>>> below: >>>> http://cxf.547215.n5.nabble.com/Closing-of-WebClient-and-Res >>>> ponse-objects-tp5748134p5782761.html >>>> To unsubscribe from Closing of WebClient and Response objects, click >>>> here >>>> >>>> . >>>> NAML >>>> >>>> >>> >>> >> > > > > > -- > View this message in context: http://cxf.547215.n5.nabble.com/Closing-of-WebClient-and-Response-objects-tp5748134p5782764.html > Sent from the cxf-user mailing list archive at Nabble.com. > -- Sergey Beryozkin Talend Community Coders http://coders.talend.com/