Basically this is what you want the retention work that you are running to look like:

public class SynchronizedComputerRetentionWork extends ComputerRetentionWork {

    @Override
    protected void doRun() {
        Queue.withLock(new Runnable() {
            @Override
            public void run() {
                synchronized (Jenkins.getInstance()) {
                    SynchronizedComputerRetentionWork.super.doRun();
                }
            }
        });
    }

}

and then you do something like

Jenkins.getInstance().getExtensionList(PeriodicWork.class).remove(ComputerRetentionWork.class);
Jenkins.getInstance().getExtensionList(PeriodicWork.class).add(new SynchronizedComputerRetentionWork());

Now all the above is more Java than Groovy, so would need translating into Groovy. Then you just put it in your init.groovy and you are fine.

As all this does is delegate back to the base method it would be "safe" if you forgot to remove it after upgrading to something with PR#1596 merged as the thread would simply get the two locks twice and they are re-entrant locks

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira

--
You received this message because you are subscribed to the Google Groups "Jenkins Issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to