cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thijs Elferink (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (CXF-4711) JAXBContextInitializer addType stopped handling recursive types (StackOverflow)
Date Thu, 07 Feb 2013 09:35:13 GMT

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

Thijs Elferink edited comment on CXF-4711 at 2/7/13 9:34 AM:
-------------------------------------------------------------

This is a testcase that fails:

{code}
package org.apache.cxf.jaxb;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

import org.junit.Test;

public class Cxf4711Tester {

	@Test
	public void testResursiveType() throws Exception {
		Set<Class<?>> classes = new HashSet<Class<?>>();
		Collection<Object> typeReferences = new ArrayList<Object>();
		JAXBContextInitializer init = new JAXBContextInitializer(null, classes, typeReferences);
		Method addClassMethod = JAXBContextInitializer.class.getDeclaredMethod("addClass", Class.class);
		addClassMethod.setAccessible(true);
		addClassMethod.invoke(init, Type2.class);
		System.out.println(classes);
	}
	
	public abstract static class Type2 extends AddressEntity<Type2> {
	}
	
	public static abstract class AddressEntity<T extends AddressEntity<T>> {
		public abstract Addressable<T> getEntity();
	}
	
	public interface Addressable<T extends AddressEntity<T>>{}
}
{code}
                
      was (Author: elferink):
    This is a testcase that fails:

{code}
package org.apache.cxf.jaxb;


import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

import org.junit.Test;

public class Cxf4711Tester {

	@Test
    public void testResursiveType() throws Exception {
        Set<Class<?>> classes = new HashSet<Class<?>>();
        Collection<Object> typeReferences = new ArrayList<Object>();
        JAXBContextInitializer init = new JAXBContextInitializer(null, classes, typeReferences);
        Method addClassMethod = JAXBContextInitializer.class.getDeclaredMethod("addClass",
Class.class);
        addClassMethod.setAccessible(true);
        addClassMethod.invoke(init, Type2.class);
        System.out.println(classes);
    }
    
    public abstract static class Type2 extends AddressEntity<Type2> {
    }
	
	public static abstract class AddressEntity<T extends AddressEntity<T>> {
		public abstract Addressable<T> getEntity();
	}
	
	public interface Addressable<T extends AddressEntity<T>>{}
}
{code}
                  
> 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
>            Priority: Blocker
>              Labels: CXF, Databinding, JAXB
>             Fix For: NeedMoreInfo
>
>
> Upgrading from 2.7.0. to 2.7.1 uncovers a stackoverflow in JAXBContextInitializer.addType
when using a recursive type definition like
> AddressEntity<T extends AddressEntity<T>>
> 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....

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message