jenkinsci/jenkins — pull request #1190 by jglick (2014-04-15 22:29:03+00:00)
Title: [FIXED JENKINS-22395] AbstractProject.getNextBuild returned deleted build

An attempt to fix [JENKINS-22395](https://issues.jenkins-ci.org/browse/JENKINS-22395) without knowing how to exactly reproduce the original bug. Logging indicates that during log rotation, `getNextBuild` is returning a build which had previously been deleted from the parent.

My hypothesis is that in the build which had been deleted, `previousBuildR.get()` was null due to collection and recreation of an earlier build, so `dropLinks` failed to update the bidirectional link from that earlier build. Thus it still pointed to the now-bogus build. The fix forces the actual previous and next builds of the currently deleted build to be computed.