Polymer

Polymer

763k Downloads

Destroying a manually attached element holder causes a stack overflow

haykam821 opened this issue ยท 0 comments

commented

The ElementHolder#destroy method also calls the HolderAttachment#destroy method if the holder is still attached. However, an implementation of the latter method, ManualAttachment#destroy, calls the ElementHolder#destroy method. This creates an infinite loop.

As a result, a stack overflow occurs:

java.lang.StackOverflowError: null
        at java.util.ArrayList.<init>(ArrayList.java:181) ~[?:?]
        at eu.pb4.polymer.virtualentity.api.ElementHolder.destroy(ElementHolder.java:239) ~[polymer-virtual-entity-0.6.0+1.20.2.jar:?]
        at eu.pb4.polymer.virtualentity.api.attachment.ManualAttachment.destroy(ManualAttachment.java:14) ~[polymer-virtual-entity-0.6.0+1.20.2.jar:?]
        at eu.pb4.polymer.virtualentity.api.ElementHolder.destroy(ElementHolder.java:244) ~[polymer-virtual-entity-0.6.0+1.20.2.jar:?]
        at eu.pb4.polymer.virtualentity.api.attachment.ManualAttachment.destroy(ManualAttachment.java:14) ~[polymer-virtual-entity-0.6.0+1.20.2.jar:?]

A workaround is to clear the attachment first:

holder.setAttachment(null);
holder.destroy();