提交 14d17c55 编写于 作者: K Kohsuke Kawaguchi

[FIXED HUDSON-8106] fixed an abstract error.

上级 1573ae80
......@@ -42,6 +42,9 @@ Upcoming changes</a>
<ul class=image>
<li class=bug>
Failure to UDP broadcast shouldn't kill the Hudson bootup process.
<li class=bug>
Fixed an <tt>AbstractMethodError</tt> in listing up executors.
(<a href="http://issues.hudson-ci.org/browse/HUDSON-8106">issue 8106</a>)
</ul>
</div><!--=TRUNK-END=-->
......
......@@ -26,6 +26,7 @@ package hudson.model;
import hudson.model.Queue.Executable;
import hudson.Util;
import hudson.FilePath;
import hudson.model.queue.Executables;
import hudson.model.queue.SubTask;
import hudson.model.queue.Tasks;
import hudson.model.queue.WorkUnit;
......@@ -269,7 +270,7 @@ public class Executor extends Thread implements ModelObject {
public int getProgress() {
Queue.Executable e = executable;
if(e==null) return -1;
long d = getEstimatedDurationFor(e);
long d = Executables.getEstimatedDurationFor(e);
if(d<0) return -1;
int num = (int)(getElapsedTime()*100/d);
......@@ -290,7 +291,7 @@ public class Executor extends Thread implements ModelObject {
if(e==null) return false;
long elapsed = getElapsedTime();
long d = getEstimatedDurationFor(e);
long d = Executables.getEstimatedDurationFor(e);
if(d>=0) {
// if it's taking 10 times longer than ETA, consider it stuck
return d*10 < elapsed;
......@@ -322,7 +323,7 @@ public class Executor extends Thread implements ModelObject {
Queue.Executable e = executable;
if(e==null) return Messages.Executor_NotAvailable();
long d = getEstimatedDurationFor(e);
long d = Executables.getEstimatedDurationFor(e);
if(d<0) return Messages.Executor_NotAvailable();
long eta = d-getElapsedTime();
......@@ -339,7 +340,7 @@ public class Executor extends Thread implements ModelObject {
Queue.Executable e = executable;
if(e==null) return -1;
long d = getEstimatedDurationFor(e);
long d = Executables.getEstimatedDurationFor(e);
if(d<0) return -1;
long eta = d-getElapsedTime();
......@@ -379,7 +380,7 @@ public class Executor extends Thread implements ModelObject {
if (isIdle())
return Math.max(finishTime, owner.getConnectTime());
else {
return Math.max(startTime + Math.max(0, getEstimatedDurationFor(executable)),
return Math.max(startTime + Math.max(0, Executables.getEstimatedDurationFor(executable)),
System.currentTimeMillis() + 15000);
}
}
......@@ -421,14 +422,13 @@ public class Executor extends Thread implements ModelObject {
/**
* Returns the estimated duration for the executable.
* Protects against {@link AbstractMethodError}s if the {@link Executable} implementation
* was compiled against Hudson < 1.383
* was compiled against Hudson < 1.383
*
* @deprecated as of 1.388
* Use {@link Executables#getEstimatedDurationFor(Executable)}
*/
public static long getEstimatedDurationFor(Executable e) {
try {
return e.getEstimatedDuration();
} catch (AbstractMethodError error) {
return e.getParent().getEstimatedDuration();
}
return Executables.getEstimatedDurationFor(e);
}
/**
......
......@@ -1116,7 +1116,7 @@ public class Queue extends ResourceController implements Saveable {
* Estimate of how long will it take to execute this executable.
* Measured in milliseconds.
*
* Please, consider using {@link Executor#getEstimatedDurationFor(Executable)}
* Please, consider using {@link Executables#getEstimatedDurationFor(Executable)}
* to protected against AbstractMethodErrors!
*
* @return -1 if it's impossible to estimate.
......
......@@ -65,4 +65,25 @@ public class Executables {
private static SubTask _getParentOf(Executable e) {
return e.getParent();
}
/**
* Returns the estimated duration for the executable.
* Protects against {@link AbstractMethodError}s if the {@link Executable} implementation
* was compiled against Hudson < 1.383
*/
public static long getEstimatedDurationFor(Executable e) {
try {
return _getEstimatedDuration(e);
} catch (AbstractMethodError error) {
return e.getParent().getEstimatedDuration();
}
}
/**
* A pointless function to work around what appears to be a HotSpot problem. See HUDSON-5756 and bug 6933067
* on BugParade for more details.
*/
private static long _getEstimatedDuration(Executable e) {
return e.getEstimatedDuration();
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册