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 1F435200C47 for ; Wed, 15 Mar 2017 14:03:55 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 1E252160B70; Wed, 15 Mar 2017 13:03:55 +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 70E07160B78 for ; Wed, 15 Mar 2017 14:03:54 +0100 (CET) Received: (qmail 36251 invoked by uid 500); 15 Mar 2017 13:03:53 -0000 Mailing-List: contact commits-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 commits@cxf.apache.org Received: (qmail 36119 invoked by uid 99); 15 Mar 2017 13:03:53 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Mar 2017 13:03:53 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 5F84FDFFD7; Wed, 15 Mar 2017 13:03:53 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: cschneider@apache.org To: commits@cxf.apache.org Date: Wed, 15 Mar 2017 13:03:53 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [1/2] cxf git commit: Move getting exchange into a method archived-at: Wed, 15 Mar 2017 13:03:55 -0000 Repository: cxf Updated Branches: refs/heads/3.1.x-fixes eab4d83fb -> ca50baa53 Move getting exchange into a method Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/ca50baa5 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/ca50baa5 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/ca50baa5 Branch: refs/heads/3.1.x-fixes Commit: ca50baa536422da01e513580c06fd5dcdf362f4c Parents: 6937ea6 Author: Christian Schneider Authored: Wed Mar 15 10:48:57 2017 +0100 Committer: Christian Schneider Committed: Wed Mar 15 14:03:40 2017 +0100 ---------------------------------------------------------------------- .../apache/cxf/transport/jms/JMSConduit.java | 42 +++++++++++++------- 1 file changed, 27 insertions(+), 15 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/ca50baa5/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java ---------------------------------------------------------------------- diff --git a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java index 8576149..8b5da16 100644 --- a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java +++ b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java @@ -364,31 +364,43 @@ public class JMSConduit extends AbstractConduit implements JMSExchangeSender, Me String correlationId = jmsMessage.getJMSCorrelationID(); LOG.log(Level.FINE, "Received reply message with correlation id " + correlationId); - // Try to correlate the incoming message with some timeout as it may have been - // added to the map after the message was sent - int count = 0; - Exchange exchange = null; - while (exchange == null && count < 100) { - exchange = correlationMap.remove(correlationId); - if (exchange == null) { - Thread.sleep(1); - } - count++; - } + Exchange exchange = getExchange(correlationId); if (exchange == null) { LOG.log(Level.WARNING, "Could not correlate message with correlationId " + correlationId); - return; + } else { + processReplyMessage(exchange, jmsMessage); } - processReplyMessage(exchange, jmsMessage); } catch (JMSException e) { throw JMSUtil.convertJmsException(e); - } catch (InterruptedException e) { - throw new RuntimeException("Interrupted while correlating", e); } } /** + * Try to correlate the incoming message with some timeout as it may have been + * added to the map after the message was sent + * + * @param correlationId + * @return exchange for correlationId or null if none was found + */ + private Exchange getExchange(String correlationId) { + int count = 0; + Exchange exchange = null; + while (exchange == null && count < 100) { + exchange = correlationMap.remove(correlationId); + if (exchange == null) { + try { + Thread.sleep(1); + } catch (InterruptedException e) { + throw new RuntimeException("Interrupted while correlating", e); + } + } + count++; + } + return exchange; + } + + /** * Process the reply message * @throws JMSException */