You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2013/12/10 20:22:27 UTC
svn commit: r1549942 - in /cxf/branches/2.7.x-fixes:
api/src/main/java/org/apache/cxf/staxutils/
rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/
rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/saaj/
Author: dkulp
Date: Tue Dec 10 19:22:26 2013
New Revision: 1549942
URL: http://svn.apache.org/r1549942
Log:
Merged revisions 1549694 via git cherry-pick from
https://svn.apache.org/repos/asf/cxf/trunk
........
r1549694 | dkulp | 2013-12-09 17:30:57 -0500 (Mon, 09 Dec 2013) | 2 lines
[CXF-5450] Fix some issues with SAAJ + Provider/Dispatch + Headers causing out of memory errors
........
Added:
cxf/branches/2.7.x-fixes/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptorTest.java (with props)
Modified:
cxf/branches/2.7.x-fixes/api/src/main/java/org/apache/cxf/staxutils/OverlayW3CDOMStreamWriter.java
cxf/branches/2.7.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapOutInterceptor.java
Modified: cxf/branches/2.7.x-fixes/api/src/main/java/org/apache/cxf/staxutils/OverlayW3CDOMStreamWriter.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/api/src/main/java/org/apache/cxf/staxutils/OverlayW3CDOMStreamWriter.java?rev=1549942&r1=1549941&r2=1549942&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/api/src/main/java/org/apache/cxf/staxutils/OverlayW3CDOMStreamWriter.java (original)
+++ cxf/branches/2.7.x-fixes/api/src/main/java/org/apache/cxf/staxutils/OverlayW3CDOMStreamWriter.java Tue Dec 10 19:22:26 2013
@@ -27,6 +27,7 @@ import javax.xml.stream.XMLStreamExcepti
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
+import org.w3c.dom.Text;
import org.apache.cxf.common.util.StringUtils;
@@ -40,6 +41,7 @@ public class OverlayW3CDOMStreamWriter e
List<Boolean> isOverlaidStack = new LinkedList<Boolean>();
boolean isOverlaid = true;
+ boolean textOverlay = false;
public OverlayW3CDOMStreamWriter(Document document) {
super(document);
@@ -80,6 +82,7 @@ public class OverlayW3CDOMStreamWriter e
}
isOverlaid = isOverlaidStack.remove(0);
super.writeEndElement();
+ textOverlay = false;
}
public void writeStartElement(String local) throws XMLStreamException {
isOverlaidStack.add(0, isOverlaid);
@@ -198,4 +201,21 @@ public class OverlayW3CDOMStreamWriter e
}
}
+ public void writeCharacters(String text) throws XMLStreamException {
+ if (!isOverlaid) {
+ super.writeCharacters(text);
+ } else if (!textOverlay) {
+ Element nd = getCurrentNode();
+ Node txt = nd.getFirstChild();
+ if (txt instanceof Text
+ && ((Text)txt).getTextContent().startsWith(text)) {
+ textOverlay = true;
+ return;
+ }
+ super.writeCharacters(text);
+ }
+
+ }
+
+
}
Modified: cxf/branches/2.7.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapOutInterceptor.java?rev=1549942&r1=1549941&r2=1549942&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapOutInterceptor.java (original)
+++ cxf/branches/2.7.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapOutInterceptor.java Tue Dec 10 19:22:26 2013
@@ -61,6 +61,7 @@ import org.apache.cxf.service.model.Serv
import org.apache.cxf.staxutils.DelegatingXMLStreamWriter;
import org.apache.cxf.staxutils.StaxUtils;
import org.apache.cxf.wsdl.EndpointReferenceUtils;
+import org.apache.cxf.staxutils.W3CDOMStreamWriter;
public class SoapOutInterceptor extends AbstractSoapInterceptor {
public static final String WROTE_ENVELOPE_START = "wrote.envelope.start";
@@ -142,6 +143,13 @@ public class SoapOutInterceptor extends
List<Header> hdrList = message.getHeaders();
for (Header header : hdrList) {
XMLStreamWriter writer = xtw;
+ if (xtw instanceof W3CDOMStreamWriter) {
+ Element nd = ((W3CDOMStreamWriter)xtw).getCurrentNode();
+ if (header.getObject() instanceof Element
+ && nd.isSameNode(((Element)header.getObject()).getParentNode())) {
+ continue;
+ }
+ }
if (header instanceof SoapHeader) {
SoapHeader soapHeader = (SoapHeader)header;
writer = new SOAPHeaderWriter(xtw, soapHeader, soapVersion, soapPrefix);
Added: cxf/branches/2.7.x-fixes/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptorTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptorTest.java?rev=1549942&view=auto
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptorTest.java (added)
+++ cxf/branches/2.7.x-fixes/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptorTest.java Tue Dec 10 19:22:26 2013
@@ -0,0 +1,81 @@
+/**
+ * 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.cxf.binding.soap.saaj;
+
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.List;
+
+import javax.xml.soap.SOAPMessage;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.transform.stream.StreamSource;
+
+import org.w3c.dom.Element;
+
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.binding.soap.Soap11;
+import org.apache.cxf.binding.soap.SoapHeader;
+import org.apache.cxf.binding.soap.TestBase;
+import org.apache.cxf.binding.soap.TestUtil;
+import org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor;
+import org.apache.cxf.headers.Header;
+import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.staxutils.W3CDOMStreamWriter;
+
+import org.junit.Before;
+import org.junit.Test;
+
+
+public class SAAJOutInterceptorTest extends TestBase {
+
+ private SoapOutInterceptor soi;
+
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+
+ soi = new SoapOutInterceptor(BusFactory.getDefaultBus());
+ }
+
+ @Test
+ public void testHandleHeader() throws Exception {
+ soapMessage = TestUtil.createEmptySoapMessage(Soap11.getInstance(), chain);
+ soapMessage.setContent(OutputStream.class, new ByteArrayOutputStream());
+
+ SOAPMessage m = SAAJFactoryResolver.createMessageFactory(soapMessage.getVersion()).createMessage();
+
+ InputStream ins = getClass().getResourceAsStream("../test-soap-header.xml");
+ m.getSOAPPart().setContent(new StreamSource(ins));
+
+ Element el = DOMUtils.getFirstElement(m.getSOAPPart().getEnvelope().getHeader());
+ List<Header> h = soapMessage.getHeaders();
+ while (el != null) {
+ h.add(new SoapHeader(DOMUtils.getElementQName(el), el));
+ el = DOMUtils.getNextElement(el);
+ }
+ soapMessage.setContent(SOAPMessage.class, m);
+ W3CDOMStreamWriter writer = new SAAJStreamWriter(m.getSOAPPart());
+ soapMessage.setContent(XMLStreamWriter.class, writer);
+ soi.handleMessage(soapMessage);
+
+ m.writeTo(System.out);
+ }
+}
Propchange: cxf/branches/2.7.x-fixes/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptorTest.java
------------------------------------------------------------------------------
svn:eol-style = native