You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2013/09/05 15:30:27 UTC

[1/2] git commit: CAMEL-6690 fixed the Memory leak SoapOutInterceptor.writeSoapEnvelopeStart with security headers

Updated Branches:
  refs/heads/camel-2.11.x 11cae92e0 -> 7965197fa
  refs/heads/camel-2.12.x 93176a323 -> 3e1198446


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


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

Branch: refs/heads/camel-2.12.x
Commit: 3e11984465195d8dbf22d697809720d92a83818f
Parents: 93176a3
Author: Willem Jiang <wi...@gmail.com>
Authored: Thu Sep 5 19:56:59 2013 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Thu Sep 5 21:15:36 2013 +0800

----------------------------------------------------------------------
 .../feature/CXFMessageDataFormatFeature.java    |  3 +-
 .../CxfMessageSoapHeaderOutInterceptor.java     | 44 ++++++++++++++++++++
 .../cxf/wssecurity/camel/MyProcessor.java       | 42 -------------------
 .../cxf/wssecurity/camel/camel-context.xml      |  4 +-
 4 files changed, 47 insertions(+), 46 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/3e119844/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/3e119844/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

http://git-wip-us.apache.org/repos/asf/camel/blob/3e119844/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/wssecurity/camel/MyProcessor.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/wssecurity/camel/MyProcessor.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/wssecurity/camel/MyProcessor.java
deleted file mode 100644
index 3a4ebe5..0000000
--- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/wssecurity/camel/MyProcessor.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * 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.wssecurity.camel;
-
-import java.io.InputStream;
-
-import javax.xml.soap.MessageFactory;
-import javax.xml.soap.SOAPMessage;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-
-/**
- * This processor is used to create a new SOAPMessage from the in message stream
- * which will be used as output message.
- */
-public class MyProcessor implements Processor {
-
-    @Override
-    public void process(Exchange exchange) throws Exception {
-        // take out the soap message as an inputStream
-        InputStream is = exchange.getIn().getBody(InputStream.class);
-        // put it as an soap message
-        SOAPMessage message = MessageFactory.newInstance().createMessage(null, is);
-        exchange.getOut().setBody(message);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/3e119844/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/wssecurity/camel/camel-context.xml
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/wssecurity/camel/camel-context.xml b/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/wssecurity/camel/camel-context.xml
index c8eb963..32f9897 100644
--- a/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/wssecurity/camel/camel-context.xml
+++ b/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/wssecurity/camel/camel-context.xml
@@ -68,15 +68,13 @@
   <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
    <route errorHandlerRef="noErrorHandler">
        <from uri="cxf:bean:route" />
-       <process ref="myProcessor" />
        <to uri="cxf:bean:service"/>
-       <process ref="myProcessor" />
    </route>
 
   </camelContext>
   
   <bean id="noErrorHandler" class="org.apache.camel.builder.NoErrorHandlerBuilder"/>
-  <bean id="myProcessor" class="org.apache.camel.component.cxf.wssecurity.camel.MyProcessor"/>
+
   
  <bean id="wss4jInInterceptor-server" class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor">
       <constructor-arg>


[2/2] git commit: CAMEL-6690 fixed the Memory leak SoapOutInterceptor.writeSoapEnvelopeStart with security headers

Posted by ni...@apache.org.
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 <wi...@gmail.com>
Authored: Thu Sep 5 21:26:41 2013 +0800
Committer: Willem Jiang <wi...@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