CAMEL-6690 fixed the Memory leak SoapOutInterceptor.writeSoapEnvelopeStart with 
security headers

Conflicts:

        
components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/wssecurity/camel/camel-context.xml


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/7965197f
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/7965197f
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/7965197f

Branch: refs/heads/camel-2.11.x
Commit: 7965197fabbdf5d1d0b1b0a04db6982e4a60ce65
Parents: 11cae92
Author: Willem Jiang <willem.ji...@gmail.com>
Authored: Thu Sep 5 21:26:41 2013 +0800
Committer: Willem Jiang <willem.ji...@gmail.com>
Committed: Thu Sep 5 21:26:41 2013 +0800

----------------------------------------------------------------------
 .../feature/CXFMessageDataFormatFeature.java    |  3 +-
 .../CxfMessageSoapHeaderOutInterceptor.java     | 44 ++++++++++++++++++++
 2 files changed, 46 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/7965197f/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..e80d985 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
@@ -23,6 +23,7 @@ import java.util.Collection;
 import javax.xml.soap.SOAPMessage;
 import javax.xml.transform.Source;
 
+import 
org.apache.camel.component.cxf.interceptors.CxfMessageSoapHeaderOutInterceptor;
 import org.apache.cxf.Bus;
 import org.apache.cxf.binding.Binding;
 import org.apache.cxf.binding.soap.SoapBinding;
@@ -32,7 +33,6 @@ import org.apache.cxf.endpoint.Client;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.interceptor.AbstractInDatabindingInterceptor;
-import org.apache.cxf.interceptor.ClientFaultConverter;
 import org.apache.cxf.jaxws.interceptors.HolderInInterceptor;
 import org.apache.cxf.jaxws.interceptors.HolderOutInterceptor;
 import org.apache.cxf.jaxws.interceptors.MessageModeInInterceptor;
@@ -85,6 +85,7 @@ public class CXFMessageDataFormatFeature extends 
AbstractDataFormatFeature {
             ep.getInInterceptors().add(new SAAJInInterceptor());          
             SAAJOutInterceptor out = new SAAJOutInterceptor();
             ep.getOutInterceptors().add(out);
+            ep.getOutInterceptors().add(new 
CxfMessageSoapHeaderOutInterceptor());
             ep.getOutInterceptors().add(new MessageModeOutInterceptor(out, 
ep.getBinding().getBindingInfo().getName()));
             fmt = SOAPMessage.class;
         } else {

http://git-wip-us.apache.org/repos/asf/camel/blob/7965197f/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/CxfMessageSoapHeaderOutInterceptor.java
----------------------------------------------------------------------
diff --git 
a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/CxfMessageSoapHeaderOutInterceptor.java
 
b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/CxfMessageSoapHeaderOutInterceptor.java
new file mode 100644
index 0000000..d1b7874
--- /dev/null
+++ 
b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/CxfMessageSoapHeaderOutInterceptor.java
@@ -0,0 +1,44 @@
+/**
+ * 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.interceptors;
+
+
+import org.apache.cxf.binding.soap.SoapMessage;
+import org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.phase.Phase;
+
+
+import javax.xml.soap.SOAPMessage;
+
+public class CxfMessageSoapHeaderOutInterceptor extends 
AbstractPhaseInterceptor<SoapMessage> {
+
+    public CxfMessageSoapHeaderOutInterceptor() {
+        super(Phase.PRE_PROTOCOL);
+        addAfter(SAAJOutInterceptor.class.getName());
+    }
+    public void handleMessage(SoapMessage message) {
+        // remove the soap header to avoid the endless loop
+        SOAPMessage saaj = message.getContent(SOAPMessage.class);
+        if (saaj != null) {
+            // AS CXF_MESSAGE already build up all the SOAP message
+            // need to clean up the soap Header from message to avoid endless 
loop
+            message.getHeaders().clear();
+        }
+
+    }
+}
\ No newline at end of file

Reply via email to