mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-12 08:25:44 +01:00
replace QuartzScheduler with a more lightweight scheduler
The new scheduler is based on the cron-utils package and uses the same cron syntax as quartz. CronScheduler was mainly introduced, because of a ClassLoader leak with the old Quartz implementation. The leak comes from shiros use of InheriatableThreadLocal in combination with the WorkerThreads of Quartz. CronScheduler uses a ThreadFactory which clears the Shiro context before a new Thread is created (see CronThreadFactory).
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package sonia.scm.schedule;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import sonia.scm.web.security.AdministrationContext;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Provider;
|
||||
|
||||
class PrivilegedRunnableFactory {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(PrivilegedRunnableFactory.class);
|
||||
|
||||
private final AdministrationContext context;
|
||||
|
||||
@Inject
|
||||
PrivilegedRunnableFactory(AdministrationContext context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public Runnable create(Provider<? extends Runnable> runnableProvider) {
|
||||
return () -> context.runAsAdmin(() -> {
|
||||
LOG.trace("create runnable from provider");
|
||||
Runnable runnable = runnableProvider.get();
|
||||
LOG.debug("execute scheduled job {}", runnable.getClass());
|
||||
runnable.run();
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user