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 A1ECA200BB7 for ; Tue, 25 Oct 2016 11:42:05 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id A0A20160AE6; Tue, 25 Oct 2016 09:42:05 +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 E8C37160AF3 for ; Tue, 25 Oct 2016 11:42:04 +0200 (CEST) Received: (qmail 14694 invoked by uid 500); 25 Oct 2016 09:41:59 -0000 Mailing-List: contact issues-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 issues@cxf.apache.org Received: (qmail 14428 invoked by uid 99); 25 Oct 2016 09:41:58 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Oct 2016 09:41:58 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 95DF22C2A6D for ; Tue, 25 Oct 2016 09:41:58 +0000 (UTC) Date: Tue, 25 Oct 2016 09:41:58 +0000 (UTC) From: "Tadayoshi Sato (JIRA)" To: issues@cxf.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Comment Edited] (CXF-7109) ClientCallback may be invoked twice when Async HTTP Transport is used MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Tue, 25 Oct 2016 09:42:05 -0000 [ https://issues.apache.org/jira/browse/CXF-7109?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15604787#comment-15604787 ] Tadayoshi Sato edited comment on CXF-7109 at 10/25/16 9:41 AM: --------------------------------------------------------------- I'm working on a pull req. I think the best way to fix this issue is to remove the callback instance from the exchange once the callback's {{handle*****}} method is invoked so any other thread cannot invoke it again within the same exchange. was (Author: tadayosi): I'm working on a pull req. > ClientCallback may be invoked twice when Async HTTP Transport is used > --------------------------------------------------------------------- > > Key: CXF-7109 > URL: https://issues.apache.org/jira/browse/CXF-7109 > Project: CXF > Issue Type: Bug > Components: Core, Transports > Affects Versions: 3.1.8 > Environment: RHEL 6.8 > Reporter: Tadayoshi Sato > > With Async HTTP Transport ({{cxf-rt-transports-http-hc}}) enabled, the {{ClientCallback}} object passed for the invocation of the client may be called twice when a failure occurs during the invocation: > {code:java} > Client client = ... > client.invoke(new ClientCallback { ... }, opName, params); > {code} > At this moment, this issue is reproduced only on RHEL 6.8, but code analysis shows that it's a general multithreading issue with Async HTTP Transport and in theory it can happen on any platform. > Here is what I've found with the code analysis: > If for some reason the target endpoint is not reachable, this issue can happen when the callback for Apache HC {{HttpAsyncClient}} \[1] is invoked and thus shuts down {{SharedOutputBuffer}} earlier than {{HTTPConduit}} tries to write it before closing the conduit itself \[2]. > \[1] https://github.com/apache/cxf/blob/cxf-3.1.8/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java#L464 > \[2] https://github.com/apache/cxf/blob/cxf-3.1.8/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/SharedOutputBuffer.java#L231 > When the above issue happens, the interceptor chain's fault observer is eventually invoked twice, once from the response workqueue thread \[3] that is spawn by the Apache HC {{HttpAsyncClient}} callback and the second time from the requesting thread at the interceptor chain \[4]; Thus the client callback is also invoked twice \[5]! > \[3] https://github.com/apache/cxf/blob/cxf-3.1.8/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java#L1177 > \[4] https://github.com/apache/cxf/blob/cxf-3.1.8/core/src/main/java/org/apache/cxf/phase/PhaseInterceptorChain.java#L366 > \[5] https://github.com/apache/cxf/blob/cxf-3.1.8/core/src/main/java/org/apache/cxf/interceptor/ClientOutFaultObserver.java#L59 > Why it happens so reliably only on RHEL 6.8 is still unclear (probably due to some thread scheduling logic specific to the kernel for RHEL 6.8), but since it's essentially an ordering issue for two distinct threads, in theory it can happen on any platforms. In general, CXF should really enforce that every client callback be invoked once and only once. -- This message was sent by Atlassian JIRA (v6.3.4#6332)