Skip to content

Commit

Permalink
Merge pull request #2188 from HubSpot/fewer_threads
Browse files Browse the repository at this point in the history
Thread and stream clean up
  • Loading branch information
ssalinas authored Mar 19, 2021
2 parents fb1a57f + 2de124f commit 136686c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}
}
Expand Down

0 comments on commit 136686c

Please # to comment.