Skip to content
Permalink
Browse files
Merge branch 'master' into JENKINS-27289
  • Loading branch information
liorhson committed May 5, 2015
2 parents ce862f0 + 56a4453 commit e166c9268e3cffbe8eab1d7a7502ac272b325a02
@@ -55,7 +55,12 @@
<!-- Record your changes in the trunk here. -->
<div id="trunk" style="display:none"><!--=TRUNK-BEGIN=-->
<ul class=image>
<li class=>
<li class=bug>
Update bundled LDAP plugin in order to restore missing help files
(<a href="https://github.com/jenkinsci/jenkins/pull/1682">PR 1682</a>)
<li class=bug>
hudson.model.Run.getLog() throws IndexOutOfBoundsException when called with maxLines=0
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-27441">issue 27441</code>)
</ul>
</div><!--=TRUNK-END=-->
<h3><a name=v1.612>What's new in 1.612</a> (2015/05/03)</h3>
@@ -1933,6 +1933,9 @@ public synchronized void save() throws IOException {
public @Nonnull List<String> getLog(int maxLines) throws IOException {
int lineCount = 0;
List<String> logLines = new LinkedList<String>();
if (maxLines == 0) {
return logLines;
}
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(getLogFile()),getCharset()));
try {
for (String line = reader.readLine(); line != null; line = reader.readLine()) {
@@ -585,12 +585,20 @@ public String call() throws IOException {
}

private File getExeFile(String execName) {
if(File.separatorChar=='\\')
execName += ".bat";

String m2Home = Util.replaceMacro(getHome(),EnvVars.masterEnvVars);

return new File(m2Home, "bin/" + execName);
if(Functions.isWindows()) {
File exeFile = new File(m2Home, "bin/" + execName + ".bat");

// since Maven 3.3 .bat files are replaced with .cmd
if (!exeFile.exists()) {
return new File(m2Home, "bin/" + execName + ".cmd");
}

return exeFile;
} else {
return new File(m2Home, "bin/" + execName);
}
}

/**
@@ -25,18 +25,27 @@
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;
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 void getDurationString() throws IOException {
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());
}

}
@@ -322,7 +322,7 @@ THE SOFTWARE.
<artifactItem>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>ldap</artifactId>
<version>1.6</version>
<version>1.11</version>
<type>hpi</type>
</artifactItem>
<artifactItem>

0 comments on commit e166c92

Please sign in to comment.