mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-10 10:36:21 +00:00
Fixing StringIndexOutOfBoundsException
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)
This commit is contained in:
1 parent
5ee9ab5451
commit
ff7f272a4b
2 files changed
+10
-9
No files matched your search
@@ -82,15 +82,16 @@ public final class PackageResult extends MetaTabulatedResult implements Comparab
|
||||
@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())
|
||||
className = id.substring(classNameStart);
|
||||
}
|
||||
|
||||
String subId = null;
|
||||
int classNameEnd = className.indexOf('/');
|
||||
if (classNameEnd > 0) {
|
||||
subId = className.substring(classNameEnd + 1);
|
||||
@@ -106,7 +107,7 @@ public final class PackageResult extends MetaTabulatedResult implements Comparab
|
||||
return child.findCorrespondingResult(subId);
|
||||
} else {
|
||||
return child;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -138,7 +138,7 @@ public abstract class TestObject extends hudson.tasks.junit.TestObject {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
TestObject next = this;
|
||||
TestObject cur = this;
|
||||
// Walk up my ancesotors from leaf to root, looking for "it"
|
||||
// Walk up my ancestors from leaf to root, looking for "it"
|
||||
// and accumulating a relative url as I go
|
||||
while (next!=null && it!=next) {
|
||||
cur = next;
|
||||
@@ -260,7 +260,7 @@ public abstract class TestObject extends hudson.tasks.junit.TestObject {
|
||||
|
||||
/**
|
||||
* Find the test result corresponding to the one identified by <code>id></code>
|
||||
* withint this test result.
|
||||
* within this test result.
|
||||
*
|
||||
* @param id The path to the original test result
|
||||
* @return A corresponding test result, or null if there is no corresponding
|
||||
|
||||
Reference in new issue
Block a user