OpenNTF / org.openntf.xsp.jakartaee

XPages Jakarta EE support libraries
Apache License 2.0
20 stars 7 forks source link

Using executors breaks the app when it reloads #574

Closed jesse-gallagher closed 1 week ago

jesse-gallagher commented 2 weeks ago

In attempting to reproduce CDI-based scheduling as seen in https://balusc.omnifaces.org/2024/10/how-to-migrate-from-ejb-to-cdi.html , I found that scheduling a bean-method-call task in the ManagedScheduledExecutorService doesn't seem to work at all, and then also creates a situation where modifying the app design means the app can't find CDI until an HTTP restart.

Other code in that method, like just a sysout, does not cause this trouble.

jesse-gallagher commented 1 week ago

It looks like it's not necessarily related to the CDI-startup bit at all. I just tried kicking off a task in the non-scheduled executor and it similarly didn't finish (without logging trouble) and also eventually broke the app.

jesse-gallagher commented 1 week ago

Interestingly, it doesn't ALWAYS cause trouble. I restarted HTTP and then immediately tried this and it worked. It could be something to do with modifying the design of the app.

jesse-gallagher commented 1 week ago

It seems like this trouble also crops up when the app unloads due to its normal timeout, so the problem is likely that any use of executors "poisons" the app such that it can't reload, and modifying the design just accelerates the process.

jesse-gallagher commented 1 week ago

I've been poking around to see how Concurrency could be "tainting" the app, and it's not clear. The trouble with not finding the CDI container seems to be that at some point the NotesContext isn't set, but it sure seems like it always should be, and debugging didn't show any times when getCurrentUnchecked() returned null. I kind of wonder if it's related to ClassLoader shuffling and Domino's tendency to aggressively re-use threads, but nothing is standing out.