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 3D870200CEC for ; Mon, 21 Aug 2017 14:19:52 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 3C75216511D; Mon, 21 Aug 2017 12:19:52 +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 32E9716511C for ; Mon, 21 Aug 2017 14:19:51 +0200 (CEST) Received: (qmail 59886 invoked by uid 500); 21 Aug 2017 12:19:49 -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 59873 invoked by uid 99); 21 Aug 2017 12:19:48 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 21 Aug 2017 12:19:48 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 780E5C0310 for ; Mon, 21 Aug 2017 12:19:48 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -1.088 X-Spam-Level: X-Spam-Status: No, score=-1.088 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, RCVD_IN_SORBS_SPAM=0.5, SPF_PASS=-0.001, URI_HEX=1.313] autolearn=disabled Authentication-Results: spamd4-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id ttYuYXjuz5Ug for ; Mon, 21 Aug 2017 12:19:45 +0000 (UTC) Received: from mail-wr0-f179.google.com (mail-wr0-f179.google.com [209.85.128.179]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id B2D105FE5F for ; Mon, 21 Aug 2017 12:19:44 +0000 (UTC) Received: by mail-wr0-f179.google.com with SMTP id p8so33398005wrf.5 for ; Mon, 21 Aug 2017 05:19:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:references:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=7mCUZGkgnqSaXiNt9oSasynsFUA0MBFId/2OHTiCcQo=; b=JWG08VCgAzXIyhHXD6IzkCKOAWsTTZuDS9y4O/SH/FzTWK+Xlvfr6kvFOJR8yRTugx eslzSaafZJSIu6fEh5Ib71HREuzbgI8A1duuOffBvC0jlwukx4A31dK0upWFnGTYFuuo zF+98knRN9ioSstWRWutLwWvkVLbIwM0fxoeXvr0b8duM2mAEG8lkx5ux2+YKjymYa4D lSaXQJWjob1AnFQ7vHmXLgs/xnr2L2lbpGNDzICtE+WI610MLUdLXnqoRYUTebvIc5Sf wmeyk5hLjlfyhXBYg+PZtkoCQsEPWsKT5IT0Cl2SyTz8jfpSFqMTtSP4LwX9P5BNxEYq nLrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=7mCUZGkgnqSaXiNt9oSasynsFUA0MBFId/2OHTiCcQo=; b=DLM0ItZiYkSlen1bSPcMEzzySqW5i4yC9/Cf7lKS3mXf9lJHxsKcl/dlsno+8OBZ9m 0rd1MbEVhawYBAnBaCEDg3xi8nftFYmcuadhj+jEppZnS8UGyHyu1g1j37IJQFeDwkup PHfKEWzzrC4K7rMPKiFszMhDMKZFApGuHSrU1N0DSNRRUN0DVYX1EB2b5hJNb2AvCzKd TBk7PKuJ7r1y6i7ahlc1DXugx7SJv3Fl7fMdAek1eqy94vcYLH7a53do8Nx8xAzMbNyG sPmPykjock3jSVV03ACXLwUkuWNLlE6MedB4W4jZlnx3swrv/PKsdO3YbOPTFNz03JZx CbTQ== X-Gm-Message-State: AHYfb5jKIyZKXDQ8K/m+qir2F/b0EAN+J5MuarUm4SCfzTsHrjzHNQ00 QOMCI00jQq9KaZ3Xm04= X-Received: by 10.80.193.2 with SMTP id l2mr12711425edf.177.1503317983838; Mon, 21 Aug 2017 05:19:43 -0700 (PDT) Received: from [192.168.2.5] (188-141-10-56.dynamic.upc.ie. [188.141.10.56]) by smtp.googlemail.com with ESMTPSA id v18sm8341935edi.66.2017.08.21.05.19.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Aug 2017 05:19:43 -0700 (PDT) From: Sergey Beryozkin 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> Message-ID: Date: Mon, 21 Aug 2017 13:19:40 +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: 8bit archived-at: Mon, 21 Aug 2017 12:19:52 -0000 This was already resolved in 3.1.13-SNAPSHOT (CXF-7478) A couple of comments. This is not a blocker given that 1) in the version you are migrating from the notion of the auto-closing the stream did not exist and 2) I showed the way this feature can still be effective in CXF 3.1.x The other point is that if you see what seems to be a blocker then do consider creating a patch to make things faster - in this case I had a time to do a quick fix, on other cases it may be possible to prioritize... Cheers Sergey On 19/08/17 19:24, sbalustar wrote: > Sergey, > > Did you get any chance to open a ticket on this issue? This is a blocker > for us. > > On Thu, Aug 17, 2017 at 11:36 AM Balakrishna Sudabathula < > bsudabathula@gmail.com> wrote: > >> Sergey, >> >> We have not created any client from our side. We are using jar file in >> our project which is developed by some other team was implemented this >> functionality. But in CXF 3.1.8 WebClient, handleResponse method first it >> is calling readEntity which it is closing the entity and later calling >> getEntity which is checking the entity is closed or not. If it is closed , >> Entity is not available Exception is throwing. >> >> >> On Thu, Aug 17, 2017 at 12:15 AM, Jose MarĂ­a Zaragoza [via CXF] < >> ml+s547215n5782769h73@n5.nabble.com> wrote: >> >>> 2017-08-16 23:18 GMT+02:00 sbalustar <[hidden email] >>> >: >>> >>>> 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; >>>> >>>> } >>>> >>>> >>>> >>>> } >>> >>> >>> >>> Hi: >>> >>> Sorry for this semi-offtopic, but there is something I don't understand >>> >>> I thought that Response.close() method performed a close in InputStream >>> object >>> associated to the underlying HttpURLConnection object. >>> >>> But I see that Response.close() only closes entity **if entity is an >>> InputStream** >>> The beginning of the thread was about if it was necessary to close >>> Response instance explicitly. >>> >>> What about if I do >>> >>> Book book = response.readEntity(Book.class) >>> >>> ? >>> >>> Should I close the response object ? >>> I see that autoclose() only is called if class is not InputStream , >>> but close() required that entity be InputStream >>> >>> I know I'm loosing something ( maybe mixing concepts ) >>> >>> Regards >>> >>> >>>> 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] < >>> http:///user/SendEmail.jtp?type=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.WebClient.doResponse(WebClient.java:1110) >>>>> >>>>>>> >>>>>>>> at >>>>>>>> >>> org.apache.cxf.jaxrs.client.WebClient.doChainedInvocation(WebClient.java:1035) >>> >>>>> >>>>>>> >>>>>>>> at >>> org.apache.cxf.jaxrs.client.WebClient.doInvoke(WebClient.java:892) >>>>> >>>>>>> >>>>>>>> at >>> org.apache.cxf.jaxrs.client.WebClient.doInvoke(WebClient.java:863) >>>>> >>>>>>> >>>>>>>> at >>> org.apache.cxf.jaxrs.client.WebClient.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- >>>>> Response-objects- >>>>>>> tp5748134p5782725.html >>>>>>> To unsubscribe from Closing of WebClient and Response objects, >>> click >>>>> here >>>>>>> < >>>>>>> . >>>>>>> NAML >>>>>>> >>>> macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml& >>>>> base=nabble.naml.namespaces.BasicNamespace-nabble.view. >>>>> web.template.NabbleNamespace-nabble.view.web.template. >>>>> NodeNamespace&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. >>>>> com/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-Response-objects- >>>>> tp5748134p5782757.html >>>>> To unsubscribe from Closing of WebClient and Response objects, click >>> here >>>>> < >>>>> . >>>>> NAML >>>>> < >>> http://cxf.547215.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&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.com/Closing-of-WebClient-and-Response-objects-tp5748134p5782758.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-Response-objects-tp5748134p5782769.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-tp5748134p5782871.html > Sent from the cxf-user mailing list archive at Nabble.com. >