Skip to content

Commit

Permalink
#2687 - MCP Tools render issue (#2688)
Browse files Browse the repository at this point in the history
* #2687 - MCP Tools render issue
  • Loading branch information
davidjgonzalez authored Aug 31, 2021
1 parent 665a942 commit 22ddcf1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com)
<!-- Keep this up to date! After a release, change the tag name to the latest release -->
[unreleased changes details]: https://github.com/Adobe-Consulting-Services/acs-aem-commons/compare/acs-aem-commons-5.0.6...HEAD

### Fixed

- #2687 - Fixes regression introduced in #2660 MCP Tools, and properly fixes setting so threads never terminate, using an "infinitely far-future" timeout.

## 5.0.8 - 2021-08-25

### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
public class ThrottledTaskRunnerImpl extends AnnotatedStandardMBean implements ThrottledTaskRunner, ThrottledTaskRunnerStats {

private static final Logger LOG = LoggerFactory.getLogger(ThrottledTaskRunnerImpl.class);
private int taskTimeout;
private long taskTimeout;
private int cooldownWaitTime;
private int maxThreads;
private double maxCpu;
Expand Down Expand Up @@ -297,6 +297,9 @@ private void initThreadPool() {
if (workerPool != null && workerPool.getMaximumPoolSize() != maxThreads) {
try {
workerPool.shutdown();
// #2660 - Remove configurable timeout/watchdog as this can result in repository corruption.
// Never thread termination
// https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/concurrent/ThreadPoolExecutor.html#%3Cinit%3E(int,int,long,java.util.concurrent.TimeUnit,java.util.concurrent.BlockingQueue)
workerPool.awaitTermination(taskTimeout, TimeUnit.MILLISECONDS);
} catch (InterruptedException ex) {
LOG.error("Timeout occurred when waiting to terminate worker pool", ex);
Expand All @@ -305,6 +308,9 @@ private void initThreadPool() {
workerPool = null;
}
if (!isRunning()) {
// #2660 - Remove configurable timeout/watchdog as this can result in repository corruption.
// Never thread termination
// https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/concurrent/ThreadPoolExecutor.html#%3Cinit%3E(int,int,long,java.util.concurrent.TimeUnit,java.util.concurrent.BlockingQueue)
workerPool = new PriorityThreadPoolExecutor(maxThreads, maxThreads, taskTimeout, TimeUnit.MILLISECONDS, workQueue);
}
}
Expand All @@ -320,9 +326,10 @@ protected void activate(ComponentContext componentContext) {

/**
* #2660 - Remove configurable timeout/watchdog as this can result in repository corruption.
* Force to -1, which disabled the timeout/watchdog
* Force to Long.MAX_VALUE, which disables the timeout/watchdog
* https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/concurrent/ThreadPoolExecutor.html#%3Cinit%3E(int,int,long,java.util.concurrent.TimeUnit,java.util.concurrent.BlockingQueue)
*/
taskTimeout = -1;
taskTimeout = Long.MAX_VALUE;

try {
memBeanName = ObjectName.getInstance("java.lang:type=Memory");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ public class TimedRunnable implements Runnable, Comparable<TimedRunnable> {
int priority;
Runnable work;
ThrottledTaskRunner runner;
int timeout;
Long timeout;
TimeUnit timeoutUnit;
Optional<CancelHandler> cancelHandler = Optional.empty();
private static final Logger LOG = LoggerFactory.getLogger(TimedRunnable.class);

public TimedRunnable(Runnable work, ThrottledTaskRunner runner, int timeout, TimeUnit timeoutUnit, int priority) {
public TimedRunnable(Runnable work, ThrottledTaskRunner runner, long timeout, TimeUnit timeoutUnit, int priority) {
this.work = work;
this.runner = runner;
this.timeout = timeout;
Expand All @@ -58,7 +58,7 @@ public TimedRunnable(Runnable work, ThrottledTaskRunner runner, int timeout, Tim
LOG.debug("Task created");
}

public TimedRunnable(Runnable work, ThrottledTaskRunner runner, int timeout, TimeUnit timeoutUnit, CancelHandler cancelHandler, int priority) {
public TimedRunnable(Runnable work, ThrottledTaskRunner runner, long timeout, TimeUnit timeoutUnit, CancelHandler cancelHandler, int priority) {
this(work, runner, timeout, timeoutUnit, priority);
this.cancelHandler = Optional.of(cancelHandler);
}
Expand Down

0 comments on commit 22ddcf1

Please sign in to comment.