Skip to content

Commit

Permalink
[FIXED JENKINS-15652] “Solving” errors by just return null from ALLRM…
Browse files Browse the repository at this point in the history
….search and reducing to one-line warnings.

@kohsuke confirms that the intent of throwing AIOOBE was to track down definite code errors;
but in at least some known occurrences of this bug, the problem is invalid data:
build records on disk with <number>s that are duplicated and/or out of order.
Since that violates the precondition of the class, we do not pretend to successfully search for such records.
At some point it would make sense to have the code detect anomalous conditions and initiate a builds folder cleanup.
Take only the last build of a given number, and discard any earlier with higher number.
I.e. just set <number> to 0 or something and ignore such builds, or rename build.xml to build-broken.xml.
  • Loading branch information
jglick committed May 28, 2013
1 parent 7874248 commit 972d8ba
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
3 changes: 3 additions & 0 deletions changelog.html
Expand Up @@ -61,6 +61,9 @@
<li class=bug>
Optimizations in fingerprint recording.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-16301">issue 16301</a>)
<li class='major bug'>
Errors searching build records when builds were misordered.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-15652">issue 15652</a>)
<li class=bug>
User icon in People broken if Jenkins root URL unconfigured.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-18118">issue 18118</a>)
Expand Down
Expand Up @@ -439,8 +439,8 @@ public R search(final int n, final Direction d) {
String msg = String.format(
"JENKINS-15652 Assertion error #1: failing to load %s #%d %s: lo=%d,hi=%d,size=%d,size2=%d",
dir, n, d, lo, hi, idOnDisk.size(), initialSize);
LOGGER.log(Level.WARNING, msg,new Exception());
throw new ArrayIndexOutOfBoundsException(msg);
LOGGER.log(Level.WARNING, msg);
return null;
}

while (lo<hi) {
Expand All @@ -451,8 +451,8 @@ public R search(final int n, final Direction d) {
String msg = String.format(
"JENKINS-15652 Assertion error #2: failing to load %s #%d %s: lo=%d,hi=%d,pivot=%d,size=%d (initial:lo=%d,hi=%d,size=%d)",
dir, n, d, lo, hi, pivot, idOnDisk.size(), initialLo, initialHi, initialSize);
LOGGER.log(Level.WARNING, msg,new Exception());
throw new ArrayIndexOutOfBoundsException(msg);
LOGGER.log(Level.WARNING, msg);
return null;
}
R r = load(idOnDisk.get(pivot), null);
if (r==null) {
Expand Down Expand Up @@ -491,7 +491,7 @@ public R search(final int n, final Direction d) {
// but don't let this kill the loading the hard way
LOGGER.log(Level.WARNING, String.format(
"JENKINS-15652 Assertion error #3: failing to load %s #%d %s: lo=%d,hi=%d,size=%d (initial:lo=%d,hi=%d,size=%d)",
dir, n,d,lo,hi,idOnDisk.size(), initialLo,initialHi,initialSize),new Exception());
dir, n,d,lo,hi,idOnDisk.size(), initialLo,initialHi,initialSize));
return null;
}
return getById(idOnDisk.get(lo-1));
Expand Down
Expand Up @@ -35,7 +35,6 @@
import java.util.SortedMap;
import java.util.logging.Level;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.jvnet.hudson.test.Bug;

/**
Expand Down Expand Up @@ -253,7 +252,6 @@ public void indexOutOfBounds() throws Exception {
assert x.n==201;
}

@Ignore("proper fix TBD")
@Bug(15652)
@Test public void outOfOrder() throws Exception {
FakeMap map = localBuilder
Expand All @@ -273,7 +271,7 @@ public void indexOutOfBounds() throws Exception {
.add(11, "2013-E")
.make();
map.entrySet(); // forces Index to be populated
map.search(3, Direction.DESC);
assertNull(map.search(3, Direction.DESC));
}

}

0 comments on commit 972d8ba

Please sign in to comment.