diff --git a/SingularityService/src/main/java/com/hubspot/singularity/SingularityManagedThreadPoolFactory.java b/SingularityService/src/main/java/com/hubspot/singularity/SingularityManagedThreadPoolFactory.java index bc44b24646..e80c3bb471 100644 --- a/SingularityService/src/main/java/com/hubspot/singularity/SingularityManagedThreadPoolFactory.java +++ b/SingularityService/src/main/java/com/hubspot/singularity/SingularityManagedThreadPoolFactory.java @@ -48,8 +48,12 @@ public synchronized ExecutorService get(String name) { public synchronized ExecutorService get(String name, int maxSize) { checkState(!stopped.get(), "already stopped"); - ExecutorService service = Executors.newFixedThreadPool( + ExecutorService service = new ThreadPoolExecutor( + 1, maxSize, + 60L, + TimeUnit.SECONDS, + new LinkedBlockingQueue<>(), new ThreadFactoryBuilder().setNameFormat(name + "-%d").build() ); executorPools.add(service); diff --git a/SingularityService/src/main/java/com/hubspot/singularity/resources/TaskResource.java b/SingularityService/src/main/java/com/hubspot/singularity/resources/TaskResource.java index 5ff663af35..a0d48a4e71 100644 --- a/SingularityService/src/main/java/com/hubspot/singularity/resources/TaskResource.java +++ b/SingularityService/src/main/java/com/hubspot/singularity/resources/TaskResource.java @@ -1395,6 +1395,10 @@ public void write(OutputStream output) throws WebApplicationException, IOExcepti requestBuilder.execute(this).get(); } catch (ExecutionException | InterruptedException e) { LOG.error("Failed or interrupted while proxying a download from Mesos", e); + } finally { + if (wrappedOutputStream != null) { + wrappedOutputStream.close(); + } } } }