mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-15 13:02:19 +00:00
Merge pull request #1591 from vb-linetco/patch-1
[FIXED JENKINS-27441] avoid IOOBE in getLog when called with 0
This commit is contained in:
commit
3bb39bbf1c
2 files changed
+29
No files matched your search
@@ -25,6 +25,9 @@
|
||||
package hudson.model;
|
||||
|
||||
import java.io.IOException;
|
||||
import hudson.model.Run.Artifact;
|
||||
import java.io.File;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.List;
|
||||
import java.util.TimeZone;
|
||||
import java.util.concurrent.Callable;
|
||||
@@ -32,11 +35,17 @@ import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.jvnet.hudson.test.Issue;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
|
||||
public class RunTest {
|
||||
|
||||
@Rule public TemporaryFolder tmp = new TemporaryFolder();
|
||||
|
||||
@Issue("JENKINS-15816")
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
@Test public void timezoneOfID() throws Exception {
|
||||
@@ -128,4 +137,21 @@ public class RunTest {
|
||||
msg = r.getDurationString();
|
||||
assertFalse(msg, msg.endsWith(" and counting"));
|
||||
}
|
||||
|
||||
@Issue("JENKINS-27441")
|
||||
@Test
|
||||
public void getLogReturnsAnEmptyListWhenCalledWith0() throws Exception {
|
||||
Job j = Mockito.mock(Job.class);
|
||||
File tempBuildDir = tmp.newFolder();
|
||||
Mockito.when(j.getBuildDir()).thenReturn(tempBuildDir);
|
||||
Run r = new Run(j, 0) {};
|
||||
File f = r.getLogFile();
|
||||
f.getParentFile().mkdirs();
|
||||
PrintWriter w = new PrintWriter(f, "utf-8");
|
||||
w.println("dummy");
|
||||
w.close();
|
||||
List<String> logLines = r.getLog(0);
|
||||
assertTrue(logLines.isEmpty());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user