Skip to content

Commit

Permalink
Merge pull request #766 from agilbert314/2.5
Browse files Browse the repository at this point in the history
Fix Infinite recursion (StackOverflowError) when serializing a SOAP object.
  • Loading branch information
cowtowncoder committed Apr 22, 2015
2 parents 3470803 + 309bb14 commit f517d63
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ public JsonSerializer<?> findSerializer(SerializationConfig config, JavaType typ
String className = rawType.getName();
String factoryName;

if (className.startsWith(PACKAGE_PREFIX_JAVAX_XML)
|| hasSupertypeStartingWith(rawType, PACKAGE_PREFIX_JAVAX_XML)) {
factoryName = SERIALIZERS_FOR_JAVAX_XML;
} else if (doesImplement(rawType, CLASS_NAME_DOM_NODE)) {
if (doesImplement(rawType, CLASS_NAME_DOM_NODE)) {
return (JsonSerializer<?>) instantiate(SERIALIZER_FOR_DOM_NODE);
}
if (className.startsWith(PACKAGE_PREFIX_JAVAX_XML) || hasSupertypeStartingWith(rawType, PACKAGE_PREFIX_JAVAX_XML)) {
factoryName = SERIALIZERS_FOR_JAVAX_XML;
} else {
return null;
}
Expand Down
20 changes: 20 additions & 0 deletions src/test/java/com/fasterxml/jackson/databind/ext/TestSOAP.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.fasterxml.jackson.databind.ext;

import javax.xml.soap.Detail;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPFactory;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

public class TestSOAP extends com.fasterxml.jackson.databind.BaseMapTest {

public void testSerializeSOAP() throws SOAPException, JsonProcessingException {
ObjectMapper objectMapper = new ObjectMapper();
SOAPFactory fac = SOAPFactory.newInstance();
Detail detailElement = fac.createDetail();
detailElement.setTextContent("test");
String result = objectMapper.writer().writeValueAsString(detailElement);
assertNotNull(result);
}
}

0 comments on commit f517d63

Please sign in to comment.