OpenLiberty / open-liberty

Open Liberty is a highly composable, fast to start, dynamic application server runtime environment
https://openliberty.io
Eclipse Public License 2.0
1.14k stars 588 forks source link

StackOverflowException when CDI scans an application with many archives #28526

Open Azquelt opened 3 months ago

Azquelt commented 3 months ago

Describe the bug
When CDI is scanning a large application with lots of archives (or with visibility of lots of shared archives), it starts with one archive and recursively scans all of its "dependencies". When all the archives have visibility of each other, (e.g. many archives in one location) they're all "dependencies" of each other which means the recursive walk will take as many stack frames as there are archives.

When there are many archives, this can lead to a StackOverflowException.

Stack trace from the error shows many lines like

at com.ibm.ws.cdi.impl.weld.BeanDeploymentArchiveImpl.scan(BeanDeploymentArchiveImpl.java:269)
at com.ibm.ws.cdi.impl.weld.BeanDeploymentArchiveImpl.scan(BeanDeploymentArchiveImpl.java:269)
at com.ibm.ws.cdi.impl.weld.BeanDeploymentArchiveImpl.scan(BeanDeploymentArchiveImpl.java:269)
at com.ibm.ws.cdi.impl.weld.BeanDeploymentArchiveImpl.scan(BeanDeploymentArchiveImpl.java:269)
at com.ibm.ws.cdi.impl.weld.BeanDeploymentArchiveImpl.scan(BeanDeploymentArchiveImpl.java:269)
at com.ibm.ws.cdi.impl.weld.BeanDeploymentArchiveImpl.scan(BeanDeploymentArchiveImpl.java:269)
at com.ibm.ws.cdi.impl.weld.BeanDeploymentArchiveImpl.scan(BeanDeploymentArchiveImpl.java:269)
...

Steps to Reproduce

Deploy an app with 1500 archives.

Expected behavior
The app should start.

Diagnostic information:

benjamin-confino commented 2 weeks ago

https://github.com/OpenLiberty/open-liberty/pull/28617 - this PR was to fix the issue but was cancelled because weld had the same issue so it wouldn't actually help