jenkinsci/gerrit-trigger-plugin — pull request #11 by bnovc (2012-02-20 17:44:15+00:00)
Title: Fix behavior of canceling old patch sets

This patch fixes behavior where if two or more patch sets were uploaded
on top of an existing build, then the canceling behavior would no
longer work.

The reason this was occuring is because scheduled() was canceling jobs,
but then removed() was being called. The intent of removed() was that
it would be called only for user involved canceling. The result of this
was that removed() was removing the current build that we cared about
and had just added.

I've fixed this problem by keeping track of which items we have
canceled. If we caused the canceling, then we ignore it. If we didn't
know about the canceling, we proceed to remove the entry.

I've also modified the runningJobs member variable to be accessed
through a singleton method. I don't know why, but runningJobs was
never being initialized and causing a NPE on every access when
I attempted to run the unmodified plugin. This adds a little bit of
confusing code, but it wasn't worth trying to debug why Java's
compiler wasn't creating an implicit constructor and initializing
the member as it should have been.