提交 c9ab4c04 编写于 作者: K kohsuke

calling updateTransientActions() from the constructor means we end up calling...

calling updateTransientActions() from the constructor means we end up calling the overrided methods in subtypes before subtype constructor kicks in. Probably not a good idea.

Instead, opted for a post-constructor hook.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@34040 71c3de6d-444a-0410-be80-ed276b4c234a
上级 a7c9760e
......@@ -223,13 +223,13 @@ public class MatrixProject extends AbstractProject<MatrixProject,MatrixBuild> im
synchronized(transientActions) {
super.updateTransientActions();
for (BuildStep step : fixNull(builders))
for (BuildStep step : builders)
transientActions.addAll(step.getProjectActions(this));
for (BuildStep step : fixNull(publishers))
for (BuildStep step : publishers)
transientActions.addAll(step.getProjectActions(this));
for (BuildWrapper step : fixNull(buildWrappers))
for (BuildWrapper step : buildWrappers)
transientActions.addAll(step.getProjectActions(this));
for (Trigger trigger : fixNull(triggers))
for (Trigger trigger : triggers)
transientActions.addAll(trigger.getProjectActions());
}
}
......
......@@ -76,6 +76,10 @@ public abstract class AbstractItem extends Actionable implements Item, HttpDelet
doSetName(name);
}
public void onCreatedFromScratch() {
// noop
}
@Exported(visibility=999)
public String getName() {
return name;
......
......@@ -217,6 +217,11 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
// make it roamable by default
canRoam = true;
}
}
@Override
public void onCreatedFromScratch() {
super.onCreatedFromScratch();
// solicit initial contributions, especially from TransientProjectActionFactory
updateTransientActions();
}
......
......@@ -2034,7 +2034,7 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
} catch (Exception e) {
throw new IllegalArgumentException(e);
}
item.onCreatedFromScratch();
item.save();
items.put(name,item);
......
......@@ -177,6 +177,12 @@ public interface Item extends PersistenceRoot, SearchableModelObject, AccessCont
*/
void onCopiedFrom(Item src);
/**
* When an item is created from scratch (instead of copied),
* this method will be invoked. Used as the post-construction initialization.
*/
void onCreatedFromScratch();
/**
* Save the settings to a file.
*
......
......@@ -198,11 +198,10 @@ public final class MavenModuleSet extends AbstractMavenProject<MavenModuleSet,Ma
protected void updateTransientActions() {
super.updateTransientActions();
// Fix for ISSUE-1149
if (modules!=null) {
for (MavenModule module: modules.values()) {
module.updateTransientActions();
}
}
if(publishers!=null) // this method can be loaded from within the onLoad method, where this might be null
for (BuildStep step : publishers)
transientActions.addAll(step.getProjectActions(this));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册