-
Bug
-
Resolution: Unresolved
-
Major
-
None
Requests are being submitted in parallel to the Thread Pool without spawning limit. It may eventually lead to the OutOfMemory issues (too many threads) or just common out of Memory issues if the requests consume too many resources.
I suggest defining a reasonable limit and making it configurable.
public class Engine extends Thread { /** * Thread pool that sets {@link #CURRENT}. */ private final ExecutorService executor = Executors.newCachedThreadPool(new ThreadFactory() { private final ThreadFactory defaultFactory = Executors.defaultThreadFactory(); public Thread newThread(final Runnable r) { Thread t = defaultFactory.newThread(new Runnable() { public void run() { CURRENT.set(Engine.this); r.run(); } }); t.setDaemon(true); return t; } });