提交 87bb29d1 编写于 作者: K kohsuke

Fixed a race condition in the ScmTest test case.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@12974 71c3de6d-444a-0410-be80-ed276b4c234a
上级 907fc05c
...@@ -423,7 +423,7 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A ...@@ -423,7 +423,7 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
Future<R> f = new AsyncFutureImpl<R>() { Future<R> f = new AsyncFutureImpl<R>() {
final RunListener r = new RunListener<AbstractBuild>(AbstractBuild.class) { final RunListener r = new RunListener<AbstractBuild>(AbstractBuild.class) {
public void onCompleted(AbstractBuild r, TaskListener listener) { public void onFinalized(AbstractBuild r) {
if(r.getProject()==AbstractProject.this && r.getNumber()>n) { if(r.getProject()==AbstractProject.this && r.getNumber()>n) {
set((R)r); set((R)r);
unregister(); unregister();
......
...@@ -920,6 +920,7 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run ...@@ -920,6 +920,7 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
result = Result.FAILURE; result = Result.FAILURE;
LOGGER.warning(toString()+": No build result is set, so marking as failure. This shouldn't happen"); LOGGER.warning(toString()+": No build result is set, so marking as failure. This shouldn't happen");
} }
RunListener.fireFinalized(this);
} }
/** /**
......
...@@ -36,7 +36,16 @@ public abstract class RunListener<R extends Run> implements ExtensionPoint { ...@@ -36,7 +36,16 @@ public abstract class RunListener<R extends Run> implements ExtensionPoint {
* the build is considered completed, so its status cannot be changed anymore. * the build is considered completed, so its status cannot be changed anymore.
*/ */
public void onCompleted(R r, TaskListener listener) {} public void onCompleted(R r, TaskListener listener) {}
/**
* Called after a build is moved to the {@link Run.State#COMPLETED} state.
*
* <p>
* At this point, all the records related to a build is written down to the disk. As such,
* {@link TaskListener} is no longer available. This happens later than {@link #onCompleted(Run, TaskListener)}.
*/
public void onFinalized(R r) {}
/** /**
* Called when a build is started (i.e. it was in the queue, and will now start running * Called when a build is started (i.e. it was in the queue, and will now start running
* on an executor) * on an executor)
...@@ -89,4 +98,14 @@ public abstract class RunListener<R extends Run> implements ExtensionPoint { ...@@ -89,4 +98,14 @@ public abstract class RunListener<R extends Run> implements ExtensionPoint {
l.onStarted(r,listener); l.onStarted(r,listener);
} }
} }
/**
* Fires the {@link #onFinalized(Run)} event.
*/
public static void fireFinalized(Run r) {
for (RunListener l : LISTENERS) {
if(l.targetType.isInstance(r))
l.onFinalized(r);
}
}
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册