Details
Description
Repro steps:
1. Create a JAX-RS endpoint method that uses an object with an enum-typed property as a matrix parameter.
2. Hit the WADL URI for the endpoint's path (or "above" the endpoint's path). Something like http://host:port/rest?_wadl, in other words.
Result:
The org.apache.cxf.jaxrs.model.wadl.WadlGenerator throws a StackOverflowError.
ERROR 2010-07-23 09:45:09.417 http-8080-1> Servlet.service() for servlet CXFServlet threw exception java.lang.StackOverflowError at java.lang.Class.privateGetPublicMethods(Class.java:2536) at java.lang.Class.getMethods(Class.java:1410) at org.apache.cxf.jaxrs.utils.InjectionUtils.getParametersFromBeanClass(InjectionUtils.java:853) at org.apache.cxf.jaxrs.model.wadl.WadlGenerator.doWriteBeanParam(WadlGenerator.java:447) at org.apache.cxf.jaxrs.model.wadl.WadlGenerator.doWriteBeanParam(WadlGenerator.java:456) at org.apache.cxf.jaxrs.model.wadl.WadlGenerator.doWriteBeanParam(WadlGenerator.java:456) at org.apache.cxf.jaxrs.model.wadl.WadlGenerator.doWriteBeanParam(WadlGenerator.java:456) at org.apache.cxf.jaxrs.model.wadl.WadlGenerator.doWriteBeanParam(WadlGenerator.java:456) ...
Example code:
@Path("/whatever") @Produces("application/json") public interface WhateverEndpoint { @GET @Path("/") public Whatever[] getWhatevers(@MatrixParam("")WhateverSearchCriteria criteria); } @XmlRootElement public class WhateverSearchCriteria { private EnumType enumValue; public EnumType getEnumValue() { return enumValue; } } @XmlRootElement public enum EnumType { Value1, Value2; }
Observations:
When I commented out the enum-typed property, the StackOverflowError went away.
I stepped through the WadlGenerator in the debugger and noticed something about getParametersFromBeanClass that might be the source of the problem. getParametersFromBeanClass gets all of the no-arg methods that begin with get and then discards "getClass". However, it doesn't discard the Enum class's getDeclaringClass method. This method returns an object of type java.lang.Class. In the debugger, I saw that all of the remaining doWriteBeanParam stack frames after the one whose type argument was the enum type had a type argument of java.lang.Class.