cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Denis Simonov (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (CXF-4711) JAXBContextInitializer addType stopped handling recursive types (StackOverflow)
Date Fri, 24 Jan 2014 15:32:38 GMT

    [ https://issues.apache.org/jira/browse/CXF-4711?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13881041#comment-13881041
] 

Denis Simonov edited comment on CXF-4711 at 1/24/14 3:31 PM:
-------------------------------------------------------------

Reproduced this bug in latest version of CXF 2.7.8 and 3.0.0-milestone1(as well as in fix
version for this bug - 2.7.2). Same situation appears in following case:
{code:title=CxfRecursiveTypeTest.java|borderStyle=solid}
public class CxfRecursiveTypeTest {

    @Test
    public void testRecursiveType() throws Exception {
        Set<Class<?>> classes = new HashSet<Class<?>>();
        Collection<Object> typeReferences = new ArrayList<Object>();
        JAXBContextInitializer jaxbContextInitializer = new JAXBContextInitializer(null, classes,
typeReferences);
        Method addClassMethod = JAXBContextInitializer.class.getDeclaredMethod("addClass",
Class.class);
        addClassMethod.setAccessible(true);
        addClassMethod.invoke(jaxbContextInitializer, Validation.class);
        System.out.println(classes);
    }

    public static class ObjectGraphProcessorItem<T extends ObjectGraphProcessorItem<T>>
{

        protected T parentItem;
        protected List<T> childItems = new ArrayList<T>();

        public ObjectGraphProcessorItem(Object object) {
            super();
        }

        public List<T> getChildItems() {
            return childItems;
        }

        public void setChildItems(List<T> childItems) {
            this.childItems = childItems;
        }

        public T getParentItem() {
            return parentItem;
        }

        public void setParentItem(T parentItem) {
            this.parentItem = parentItem;
        }
    }

    public static class Validation extends ObjectGraphProcessorItem<Validation> implements
Serializable {

        public Validation() {
            super(null);
        }

        public Validation(Object object) {
            super(object);
        }
    }
}
{code}


was (Author: deni_s):
Reproduced this bug in latest version of CXF 2.7.8 and 3.0.0-milestone1(as well as in fix
version for this bug - 2.7.2). Same situation appears in following case:
public class CxfRecursiveTypeTest {

    @Test
    public void testRecursiveType() throws Exception {
        Set<Class<?>> classes = new HashSet<Class<?>>();
        Collection<Object> typeReferences = new ArrayList<Object>();
        JAXBContextInitializer jaxbContextInitializer = new JAXBContextInitializer(null, classes,
typeReferences);
        Method addClassMethod = JAXBContextInitializer.class.getDeclaredMethod("addClass",
Class.class);
        addClassMethod.setAccessible(true);
        addClassMethod.invoke(jaxbContextInitializer, Validation.class);
        System.out.println(classes);
    }

    public static class ObjectGraphProcessorItem<T extends ObjectGraphProcessorItem<T>>
{

        protected T parentItem;
        protected List<T> childItems = new ArrayList<T>();

        public ObjectGraphProcessorItem(Object object) {
            super();
        }

        public List<T> getChildItems() {
            return childItems;
        }

        public void setChildItems(List<T> childItems) {
            this.childItems = childItems;
        }

        public T getParentItem() {
            return parentItem;
        }

        public void setParentItem(T parentItem) {
            this.parentItem = parentItem;
        }
    }

    public static class Validation extends ObjectGraphProcessorItem<Validation> implements
Serializable {

        public Validation() {
            super(null);
        }

        public Validation(Object object) {
            super(object);
        }
    }
}

> JAXBContextInitializer addType stopped handling recursive types (StackOverflow) 
> --------------------------------------------------------------------------------
>
>                 Key: CXF-4711
>                 URL: https://issues.apache.org/jira/browse/CXF-4711
>             Project: CXF
>          Issue Type: Bug
>          Components: JAXB Databinding
>    Affects Versions: 2.7.1
>            Reporter: Thijs Elferink
>            Assignee: Daniel Kulp
>            Priority: Blocker
>              Labels: CXF, Databinding, JAXB
>             Fix For: 2.7.2
>
>
> Upgrading from 2.7.0. to 2.7.1 uncovers a stackoverflow in JAXBContextInitializer.addType
when using a recursive type definition like
> {code}
> public static abstract class AddressEntity<T extends AddressEntity<T>> {
> 	public abstract Addressable<T> getEntity();
> }
> 	
> public interface Addressable<T extends AddressEntity<T>>{}
> {code}
> {code}
> java.lang.StackOverflowError
> 	at java.lang.Class.getDeclaredConstructor(Class.java:2001)
> 	at org.apache.cxf.common.util.ReflectionUtil$2.run(ReflectionUtil.java:67)
> 	at org.apache.cxf.common.util.ReflectionUtil$2.run(ReflectionUtil.java:64)
> 	at java.security.AccessController.doPrivileged(Native Method)
> 	at org.apache.cxf.common.util.ReflectionUtil.getDeclaredConstructor(ReflectionUtil.java:64)
> 	at org.apache.cxf.common.jaxb.JAXBUtils.getValidClass(JAXBUtils.java:518)
> 	at org.apache.cxf.jaxb.JAXBContextInitializer.addClass(JAXBContextInitializer.java:274)
> 	at org.apache.cxf.jaxb.JAXBContextInitializer.addType(JAXBContextInitializer.java:222)
> 	at org.apache.cxf.jaxb.JAXBContextInitializer.addType(JAXBContextInitializer.java:212)
> 	at org.apache.cxf.jaxb.JAXBContextInitializer.addType(JAXBContextInitializer.java:225)
> 	at org.apache.cxf.jaxb.JAXBContextInitializer.addType(JAXBContextInitializer.java:212)
> 	at org.apache.cxf.jaxb.JAXBContextInitializer.addType(JAXBContextInitializer.java:260)
> 	at org.apache.cxf.jaxb.JAXBContextInitializer.addType(JAXBContextInitializer.java:212)
> 	at org.apache.cxf.jaxb.JAXBContextInitializer.addType(JAXBContextInitializer.java:227)
> 	at org.apache.cxf.jaxb.JAXBContextInitializer.addType(JAXBContextInitializer.java:212)
> 	at org.apache.cxf.jaxb.JAXBContextInitializer.addType(JAXBContextInitializer.java:260)
> 	at org.apache.cxf.jaxb.JAXBContextInitializer.addType(JAXBContextInitializer.java:212)
> 	at org.apache.cxf.jaxb.JAXBContextInitializer.addType(JAXBContextInitializer.java:227)
> 	at org.apache.cxf.jaxb.JAXBContextInitializer.addType(JAXBContextInitializer.java:212)
> 	at org.apache.cxf.jaxb.JAXBContextInitializer.addType(JAXBContextInitializer.java:260)
> etc....
> {code}



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Mime
View raw message