FactoryBuilderSupport StackOverflow

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

FactoryBuilderSupport StackOverflow

David Durham, Jr.
Hi all,

I have a class extending FactoryBuilderSupport which registers a
factory for an object that takes no arguments. When used, it will
cause a StackOverflow.  Has anyone seen this before and know what the
cause/solution is?

ObjectFactory code:

  class DequeueFactory extends AbstractFactory {

    public Object newInstance(FactoryBuilderSupport builder, Object
name, Object value, Map attributes)
    throws InstantiationException, IllegalAccessException {
      def dequeue = new Dequeue()
      percl.add(dequeue)
      return dequeue
    }

    @Override
    public boolean isLeaf() {
      return true
    }

    @Override
    public boolean isHandlesNodeChildren() {
      return false
    }

  }

Example usage:

    def script = mybuilder.script {
      dequeue()
    }


This code will cause the StackOverflowException below.

java.lang.StackOverflowError
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at groovy.lang.Closure.call(Closure.java:416)
at groovy.lang.Closure.call(Closure.java:408)
at groovy.util.FactoryBuilderSupport.dispatchNodeCall(FactoryBuilderSupport.java:889)
at groovy.util.FactoryBuilderSupport.doInvokeMethod(FactoryBuilderSupport.java:781)
at groovy.util.FactoryBuilderSupport.invokeMethod(FactoryBuilderSupport.java:501)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
at com.BuilderTest.dequeue(BuilderTest.groovy:75)
at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:384)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:69)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:158)
at comBuilderTest$_dequeue_closure7.doCall(BuilderTest.groovy:76)
at com.BuilderTest$_dequeue_closure7.doCall(BuilderTest.groovy)
at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at
......
Reply | Threaded
Open this post in threaded view
|

Re: FactoryBuilderSupport StackOverflow

David Durham, Jr.
This is not an issue with FactoryBuilderSupport.

Problem was that my unit test function was also called dequeue.

  @Test
  void dequeue() {
    def script = myBuilder.script {
      dequeue()
    }

    assert '[{"Dequeue"}]' == script.toJson()
  }


This isn't an issue for other tests because the arguments didn't
match.  Sorry for the noise.

On Thu, Jun 15, 2017 at 5:29 PM, David Durham <[hidden email]> wrote:

> Hi all,
>
> I have a class extending FactoryBuilderSupport which registers a
> factory for an object that takes no arguments. When used, it will
> cause a StackOverflow.  Has anyone seen this before and know what the
> cause/solution is?
>
> ObjectFactory code:
>
>   class DequeueFactory extends AbstractFactory {
>
>     public Object newInstance(FactoryBuilderSupport builder, Object
> name, Object value, Map attributes)
>     throws InstantiationException, IllegalAccessException {
>       def dequeue = new Dequeue()
>       percl.add(dequeue)
>       return dequeue
>     }
>
>     @Override
>     public boolean isLeaf() {
>       return true
>     }
>
>     @Override
>     public boolean isHandlesNodeChildren() {
>       return false
>     }
>
>   }
>
> Example usage:
>
>     def script = mybuilder.script {
>       dequeue()
>     }
>
>
> This code will cause the StackOverflowException below.
>
> java.lang.StackOverflowError
> at java.lang.ClassLoader.defineClass1(Native Method)
> at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
> at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
> at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
> at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
> at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
> at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
> at groovy.lang.Closure.call(Closure.java:416)
> at groovy.lang.Closure.call(Closure.java:408)
> at groovy.util.FactoryBuilderSupport.dispatchNodeCall(FactoryBuilderSupport.java:889)
> at groovy.util.FactoryBuilderSupport.doInvokeMethod(FactoryBuilderSupport.java:781)
> at groovy.util.FactoryBuilderSupport.invokeMethod(FactoryBuilderSupport.java:501)
> at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:48)
> at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
> at com.BuilderTest.dequeue(BuilderTest.groovy:75)
> at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:498)
> at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
> at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
> at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:384)
> at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
> at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:69)
> at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:158)
> at comBuilderTest$_dequeue_closure7.doCall(BuilderTest.groovy:76)
> at com.BuilderTest$_dequeue_closure7.doCall(BuilderTest.groovy)
> at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:498)
> at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
> at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
> at
> ......