Return-Path: X-Original-To: apmail-camel-commits-archive@www.apache.org Delivered-To: apmail-camel-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E105710EFD for ; Sun, 20 Oct 2013 08:41:00 +0000 (UTC) Received: (qmail 71012 invoked by uid 500); 20 Oct 2013 08:40:48 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 70906 invoked by uid 500); 20 Oct 2013 08:40:45 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 70880 invoked by uid 99); 20 Oct 2013 08:40:45 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 20 Oct 2013 08:40:45 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 16D4044B0D; Sun, 20 Oct 2013 08:40:44 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ningjiang@apache.org To: commits@camel.apache.org Date: Sun, 20 Oct 2013 08:40:46 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [4/4] git commit: CAMEL-6243 Fixed the NPE of ClientFaultConverter when receiving a soapfault with the CFX_MESSAGE dataformat CAMEL-6243 Fixed the NPE of ClientFaultConverter when receiving a soapfault with the CFX_MESSAGE dataformat Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/ec779785 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/ec779785 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/ec779785 Branch: refs/heads/camel-2.10.x Commit: ec779785b97b740d3e336574c6527aba94d31b1e Parents: 422d3f3 Author: Willem Jiang Authored: Sun Oct 20 16:25:52 2013 +0800 Committer: Willem Jiang Committed: Sun Oct 20 16:31:41 2013 +0800 ---------------------------------------------------------------------- .../cxf/feature/AbstractDataFormatFeature.java | 17 +++++++ .../feature/CXFMessageDataFormatFeature.java | 1 + .../cxf/feature/PayLoadDataFormatFeature.java | 11 +---- .../cxf/CxfGreeterCXFMessageRouterTest.java | 2 + ...xfGreeterCXFMessageWithoutSEIRouterTest.java | 50 ++++++++++++++++++++ ...GreeterEndpointCxfMessageWithoutSEIBeans.xml | 47 ++++++++++++++++++ 6 files changed, 118 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/ec779785/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/AbstractDataFormatFeature.java ---------------------------------------------------------------------- diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/AbstractDataFormatFeature.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/AbstractDataFormatFeature.java index 92acf64..857b532 100644 --- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/AbstractDataFormatFeature.java +++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/AbstractDataFormatFeature.java @@ -17,12 +17,15 @@ package org.apache.camel.component.cxf.feature; +import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.Set; +import org.apache.cxf.endpoint.Client; import org.apache.cxf.feature.AbstractFeature; +import org.apache.cxf.interceptor.ClientFaultConverter; import org.apache.cxf.interceptor.Interceptor; import org.apache.cxf.message.Message; import org.apache.cxf.phase.PhaseInterceptor; @@ -32,11 +35,18 @@ import org.slf4j.Logger; * The abstract class for the data format feature */ public abstract class AbstractDataFormatFeature extends AbstractFeature { + protected static final Collection> REMOVING_FAULT_IN_INTERCEPTORS; + + static { + REMOVING_FAULT_IN_INTERCEPTORS = new ArrayList>(); + REMOVING_FAULT_IN_INTERCEPTORS.add(ClientFaultConverter.class); + } // The interceptors which need to be keeped protected Set inInterceptorNames = new HashSet(); protected Set outInterceptorNames = new HashSet(); protected abstract Logger getLogger(); + @Deprecated // It will be removed in Camel 3.0 @@ -116,6 +126,13 @@ public abstract class AbstractDataFormatFeature extends AbstractFeature { } } + protected void removeFaultInInterceptorFromClient(Client client) { + removeInterceptors(client.getInFaultInterceptors(), REMOVING_FAULT_IN_INTERCEPTORS); + removeInterceptors(client.getEndpoint().getService().getInFaultInterceptors(), REMOVING_FAULT_IN_INTERCEPTORS); + removeInterceptors(client.getEndpoint().getInFaultInterceptors(), REMOVING_FAULT_IN_INTERCEPTORS); + removeInterceptors(client.getEndpoint().getBinding().getInFaultInterceptors(), REMOVING_FAULT_IN_INTERCEPTORS); + } + public void addInIntercepters(List> interceptors) { for (Interceptor interceptor : interceptors) { inInterceptorNames.add(interceptor.getClass().getName()); http://git-wip-us.apache.org/repos/asf/camel/blob/ec779785/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/CXFMessageDataFormatFeature.java ---------------------------------------------------------------------- diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/CXFMessageDataFormatFeature.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/CXFMessageDataFormatFeature.java index ad1147d..e45df29 100644 --- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/CXFMessageDataFormatFeature.java +++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/CXFMessageDataFormatFeature.java @@ -69,6 +69,7 @@ public class CXFMessageDataFormatFeature extends AbstractDataFormatFeature { @Override public void initialize(Client client, Bus bus) { + removeFaultInInterceptorFromClient(client); setupEndpoint(client.getEndpoint()); } http://git-wip-us.apache.org/repos/asf/camel/blob/ec779785/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/PayLoadDataFormatFeature.java ---------------------------------------------------------------------- diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/PayLoadDataFormatFeature.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/PayLoadDataFormatFeature.java index 4642358..bf6ec31 100644 --- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/PayLoadDataFormatFeature.java +++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/PayLoadDataFormatFeature.java @@ -44,11 +44,8 @@ import org.slf4j.LoggerFactory; */ public class PayLoadDataFormatFeature extends AbstractDataFormatFeature { private static final Logger LOG = LoggerFactory.getLogger(PayLoadDataFormatFeature.class); - private static final Collection> REMOVING_FAULT_IN_INTERCEPTORS; private static final boolean DEFAULT_ALLOW_STREAMING; static { - REMOVING_FAULT_IN_INTERCEPTORS = new ArrayList>(); - REMOVING_FAULT_IN_INTERCEPTORS.add(ClientFaultConverter.class); String s = System.getProperty("org.apache.camel.component.cxf.streaming"); DEFAULT_ALLOW_STREAMING = s == null || Boolean.parseBoolean(s); @@ -163,11 +160,5 @@ public class PayLoadDataFormatFeature extends AbstractDataFormatFeature { } } } - private void removeFaultInInterceptorFromClient(Client client) { - removeInterceptors(client.getInFaultInterceptors(), REMOVING_FAULT_IN_INTERCEPTORS); - removeInterceptors(client.getEndpoint().getService().getInFaultInterceptors(), REMOVING_FAULT_IN_INTERCEPTORS); - removeInterceptors(client.getEndpoint().getInFaultInterceptors(), REMOVING_FAULT_IN_INTERCEPTORS); - removeInterceptors(client.getEndpoint().getBinding().getInFaultInterceptors(), REMOVING_FAULT_IN_INTERCEPTORS); - } - + } http://git-wip-us.apache.org/repos/asf/camel/blob/ec779785/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfGreeterCXFMessageRouterTest.java ---------------------------------------------------------------------- diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfGreeterCXFMessageRouterTest.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfGreeterCXFMessageRouterTest.java index 0b7283a..5368b3e 100644 --- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfGreeterCXFMessageRouterTest.java +++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfGreeterCXFMessageRouterTest.java @@ -18,6 +18,7 @@ package org.apache.camel.component.cxf; import javax.xml.ws.Endpoint; +import org.apache.camel.builder.NoErrorHandlerBuilder; import org.apache.camel.builder.RouteBuilder; import org.apache.hello_world_soap_http.GreeterImpl; import org.junit.AfterClass; @@ -47,6 +48,7 @@ public class CxfGreeterCXFMessageRouterTest extends AbstractCXFGreeterRouterTest protected RouteBuilder createRouteBuilder() { return new RouteBuilder() { public void configure() { + context.setErrorHandlerBuilder(new NoErrorHandlerBuilder()); from("cxf:bean:routerEndpoint?dataFormat=CXF_MESSAGE&publishedEndpointUrl=http://www.simple.com/services/test") .to("cxf:bean:serviceEndpoint?dataFormat=CXF_MESSAGE"); } http://git-wip-us.apache.org/repos/asf/camel/blob/ec779785/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfGreeterCXFMessageWithoutSEIRouterTest.java ---------------------------------------------------------------------- diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfGreeterCXFMessageWithoutSEIRouterTest.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfGreeterCXFMessageWithoutSEIRouterTest.java new file mode 100644 index 0000000..cbc809f --- /dev/null +++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfGreeterCXFMessageWithoutSEIRouterTest.java @@ -0,0 +1,50 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.cxf; + +import javax.xml.ws.Endpoint; + +import org.apache.hello_world_soap_http.GreeterImpl; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +public class CxfGreeterCXFMessageWithoutSEIRouterTest extends CxfGreeterCXFMessageRouterTest { + + protected static Endpoint endpoint; + @AfterClass + public static void stopService() { + if (endpoint != null) { + endpoint.stop(); + } + } + + + @BeforeClass + public static void startService() { + Object implementor = new GreeterImpl(); + String address = "http://localhost:" + getPort1() + + "/CxfGreeterCXFMessageWithoutSEIRouterTest/SoapContext/SoapPort"; + endpoint = Endpoint.publish(address, implementor); + } + + @Override + protected ClassPathXmlApplicationContext createApplicationContext() { + return new ClassPathXmlApplicationContext("org/apache/camel/component/cxf/GreeterEndpointCxfMessageWithoutSEIBeans.xml"); + } + +} http://git-wip-us.apache.org/repos/asf/camel/blob/ec779785/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/GreeterEndpointCxfMessageWithoutSEIBeans.xml ---------------------------------------------------------------------- diff --git a/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/GreeterEndpointCxfMessageWithoutSEIBeans.xml b/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/GreeterEndpointCxfMessageWithoutSEIBeans.xml new file mode 100644 index 0000000..5d91e8d --- /dev/null +++ b/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/GreeterEndpointCxfMessageWithoutSEIBeans.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + \ No newline at end of file