Skip to content
Permalink
Browse files

[FIXED JENKINS-22681] Fix of JENKINS-19418 should have used getById, …

…not load, to avoid reloading the last build gratuitously.

(cherry picked from commit b6b7bfd)

Conflicts:
	changelog.html
  • Loading branch information
jglick authored and olivergondza committed May 14, 2014
1 parent 4c4ce9c commit 701045e6a27bb93ba739b111505d01c238ad455e
@@ -509,7 +509,7 @@ public R get(int n) {
return getById(idOnDisk.get(lo-1));
case EXACT:
if (hi<=0) return null;
R r = load(idOnDisk.get(hi-1), null);
R r = getById(idOnDisk.get(hi-1));
if (r==null) return null;

int found = getNumberOf(r);
@@ -149,6 +149,7 @@ public void search() {
assertNull(a.search(-99, Direction.DESC));
}

@Bug(19418)
@Test
public void searchExactWhenIndexedButSoftReferenceExpired() throws IOException {
final FakeMap m = localExpiredBuilder.add(1, "A").add(2, "B").make();
@@ -161,6 +162,24 @@ public void searchExactWhenIndexedButSoftReferenceExpired() throws IOException {
assertNull(m.search(0, Direction.EXACT));
}

@Bug(22681)
@Test public void exactSearchShouldNotReload() throws Exception {
FakeMap m = localBuilder.add(1, "A").add(2, "B").make();
assertNull(m.search(0, Direction.EXACT));
Build a = m.search(1, Direction.EXACT);
a.asserts(1, "A");
Build b = m.search(2, Direction.EXACT);
b.asserts(2, "B");
assertNull(m.search(0, Direction.EXACT));
assertSame(a, m.search(1, Direction.EXACT));
assertSame(b, m.search(2, Direction.EXACT));
assertNull(m.search(3, Direction.EXACT));
assertNull(m.search(0, Direction.EXACT));
assertSame(a, m.search(1, Direction.EXACT));
assertSame("#2 should not have been reloaded by searching for #3", b, m.search(2, Direction.EXACT));
assertNull(m.search(3, Direction.EXACT));
}

/**
* If load fails, search needs to gracefully handle it
*/
@@ -82,4 +82,9 @@ public void asserts(int n, String id) {
assert this.n==n;
assert this.id.equals(id);
}

@Override public String toString() {
return "Build #" + n + " [" + id + "] @" + hashCode();
}

}

0 comments on commit 701045e

Please sign in to comment.
You can’t perform that action at this time.