提交 ad413c55 编写于 作者: E Erik Ramfelt

[FIXED JENKINS-10182] Used Util.fixNull() to handle the case when a jobs description is null

上级 fe290d75
......@@ -27,6 +27,7 @@ import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import hudson.Extension;
import hudson.ExtensionPoint;
import hudson.PermalinkList;
import hudson.Util;
import hudson.cli.declarative.CLIResolver;
import hudson.model.Descriptor.FormException;
import hudson.model.Fingerprint.Range;
......@@ -1002,7 +1003,7 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
if (req.getMethod().equals("GET")) {
//read
rsp.setContentType("text/plain;charset=UTF-8");
rsp.getWriter().write(this.getDescription());
rsp.getWriter().write(Util.fixNull(this.getDescription()));
return;
}
if (req.getMethod().equals("POST")) {
......
......@@ -26,6 +26,7 @@ package hudson.model;
import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
import com.gargoylesoftware.htmlunit.WebAssert;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.TextPage;
import hudson.util.TextFile;
import java.io.IOException;
......@@ -227,4 +228,15 @@ public class JobTest extends HudsonTestCase {
assertEquals(2, r.getArtifactsUpTo(2).size());
assertEquals(1, r.getArtifactsUpTo(1).size());
}
@Bug(10182)
public void testEmptyDescriptionReturnsEmptyPage() throws Exception {
// A NPE was thrown if a job had a null (empty) description.
WebClient wc = createWebClient();
FreeStyleProject project = createFreeStyleProject("project");
project.setDescription("description");
assertEquals("description", ((TextPage) wc.goTo("job/project/description", "text/plain")).getContent());
project.setDescription(null);
assertEquals("", ((TextPage) wc.goTo("job/project/description", "text/plain")).getContent());
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册