Skip to content

Commit

Permalink
[FIXED JENKINS-10182] Used Util.fixNull() to handle the case when a j…
Browse files Browse the repository at this point in the history
…obs description is null
  • Loading branch information
redsolo committed Jul 8, 2011
1 parent fe290d7 commit ad413c5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion core/src/main/java/hudson/model/Job.java
Expand Up @@ -27,6 +27,7 @@
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;
Expand Down Expand Up @@ -1002,7 +1003,7 @@ public void doDescription(StaplerRequest req, StaplerResponse rsp)
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")) {
Expand Down
12 changes: 12 additions & 0 deletions test/src/test/java/hudson/model/JobTest.java
Expand Up @@ -26,6 +26,7 @@
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;
Expand Down Expand Up @@ -227,4 +228,15 @@ public void testGetArtifactsUpTo() throws Exception {
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());
}
}

0 comments on commit ad413c5

Please sign in to comment.