Skip to content

Commit

Permalink
Added assertion as suggested in JENKINS-22767.
Browse files Browse the repository at this point in the history
  • Loading branch information
jglick committed Dec 29, 2014
1 parent bacca38 commit 1078e6b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Expand Up @@ -468,7 +468,8 @@ protected synchronized R load(File dataDir, Index editInPlace) {
Index copy = editInPlace!=null ? editInPlace : new Index(index);

BuildReference<R> ref = createReference(r);
copy.byNumber.put(getNumberOf(r),ref);
BuildReference<R> old = copy.byNumber.put(getNumberOf(r), ref);
assert old == null || old.get() == null : "tried to overwrite " + old + " with " + ref;

if (editInPlace==null) index = copy;

Expand Down
7 changes: 6 additions & 1 deletion core/src/main/java/jenkins/model/lazy/BuildReference.java
Expand Up @@ -66,7 +66,7 @@ public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;

BuildReference that = (BuildReference) o;
BuildReference<?> that = (BuildReference) o;
return id.equals(that.id);

}
Expand All @@ -76,6 +76,11 @@ public int hashCode() {
return id.hashCode();
}

@Override public String toString() {
R r = get();
return r != null ? r.toString() : id;
}

/**
* An abstraction of {@link Reference}.
* @since 1.548
Expand Down

0 comments on commit 1078e6b

Please sign in to comment.