Commit
I'm not really sure what this code is doing or what ID is supposed to look like. So this is just a minimum-intrusion change to avoid an exception. java.lang.StringIndexOutOfBoundsException: String index out of range: -1 at java.lang.String.substring(String.java:1875) at hudson.tasks.junit.PackageResult.findCorrespondingResult(PackageResult.java:86) at hudson.tasks.junit.TestResult.findCorrespondingResult(TestResult.java:295) at hudson.tasks.test.AbstractTestResultAction.findCorrespondingResult(AbstractTestResultAction.java:183) at hudson.tasks.test.TestResult.getResultInBuild(TestResult.java:162) at hudson.tasks.junit.History.getList(History.java:82) at hudson.tasks.junit.History$1.createDataSet(History.java:105) at hudson.tasks.junit.History$GraphImpl.createGraph(History.java:169) at hudson.util.Graph.render(Graph.java:87) at hudson.util.Graph.doPng(Graph.java:98)
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,15 +82,16 @@ public synchronized String getSafeName() { | |
@Override | ||
public TestResult findCorrespondingResult(String id) { | ||
String myID = safe(getName()); | ||
|
||
int base = id.indexOf(myID); | ||
String className; | ||
String subId = null; | ||
String className = id; // fall back value | ||
if (base > 0) { | ||
int classNameStart = base + myID.length() + 1; | ||
className = id.substring(classNameStart); | ||
} else { | ||
className = id; | ||
} | ||
if (classNameStart<id.length()) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
kohsuke
Author
Member
|
||
className = id.substring(classNameStart); | ||
} | ||
This comment has been minimized.
Sorry, something went wrong.
jglick
Member
|
||
|
||
String subId = null; | ||
int classNameEnd = className.indexOf('/'); | ||
if (classNameEnd > 0) { | ||
subId = className.substring(classNameEnd + 1); | ||
|
@@ -106,7 +107,7 @@ public TestResult findCorrespondingResult(String id) { | |
return child.findCorrespondingResult(subId); | ||
} else { | ||
return child; | ||
} | ||
} | ||
} | ||
|
||
return null; | ||
|
1 comment
on commit ff7f272
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Retroactively filed JENKINS-17721.
This will cause different behavior if
classNameStart == id.length()
which previously would have setclassName
to""
(though I do not know if that would ever actually happen).