Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-48389

Remoting Engine creates Executor service with unlimited number of threads

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • remoting
    • 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;
              }
          });
      

            Unassigned Unassigned
            oleg_nenashev Oleg Nenashev
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: