提交 6994fa04 编写于 作者: K kohsuke

fixed NPE when no build has run yet.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@1727 71c3de6d-444a-0410-be80-ed276b4c234a
上级 4e61aebe
......@@ -32,6 +32,7 @@ import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletResponse;
import java.awt.Color;
import java.awt.Paint;
import java.io.File;
......@@ -558,6 +559,10 @@ public abstract class Job<JobT extends Job<JobT,RunT>, RunT extends Run<JobT,Run
* Returns the graph that shows how long each build took.
*/
public void doBuildTimeGraph( StaplerRequest req, StaplerResponse rsp ) throws IOException {
if(getLastBuild()==null) {
rsp.setStatus(HttpServletResponse.SC_NOT_FOUND);
return;
}
if(req.checkIfModified(getLastBuild().getTimestamp(),rsp))
return;
ChartUtil.generateGraph(req,rsp, createBuildTimeTrendChart(),500,400);
......@@ -568,6 +573,10 @@ public abstract class Job<JobT extends Job<JobT,RunT>, RunT extends Run<JobT,Run
* Loaded lazily by AJAX.
*/
public void doBuildTimeGraphMap( StaplerRequest req, StaplerResponse rsp ) throws IOException {
if(getLastBuild()==null) {
rsp.setStatus(HttpServletResponse.SC_NOT_FOUND);
return;
}
if(req.checkIfModified(getLastBuild().getTimestamp(),rsp))
return;
ChartUtil.generateClickableMap(req,rsp, createBuildTimeTrendChart(),500,400);
......
......@@ -3,6 +3,8 @@
<l:layout title="Build time trend">
<st:include page="sidepanel.jelly" />
<l:main-panel>
<j:choose>
<j:when test="${it.builds.size()&gt;1">
<div align="center">
<img src="buildTimeGraph" width="500" height="400" lazymap="buildTimeGraphMap"/>
</div>
......@@ -34,6 +36,11 @@
</j:forEach>
</table>
</div>
</j:when>
<j:otherwise>
More than 1 builds are needed for the trend report.
</j:otherwise>
</j:choose>
</l:main-panel>
</l:layout>
</j:jelly>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册