提交 a30ee829 编写于 作者: K kohsuke
上级 5670006d
......@@ -455,15 +455,15 @@ public abstract class Descriptor<T extends Describable<T>> implements Saveable {
if(!Modifier.isAbstract(m.getDeclaringClass().getModifiers())) {
// this class overrides newInstance(StaplerRequest).
// maintain the backward compatible behavior
return newInstance(req);
return verifyNewInstance(newInstance(req));
} else {
if (req==null) {
// yes, req is supposed to be always non-null, but see the note above
return clazz.newInstance();
return verifyNewInstance(clazz.newInstance());
}
// new behavior as of 1.206
return req.bindJSON(clazz,formData);
return verifyNewInstance(req.bindJSON(clazz,formData));
}
} catch (NoSuchMethodException e) {
throw new AssertionError(e); // impossible
......@@ -474,6 +474,18 @@ public abstract class Descriptor<T extends Describable<T>> implements Saveable {
}
}
/**
* Look out for a typical error a plugin developer makes.
* See http://hudson.361315.n4.nabble.com/Help-Hint-needed-Post-build-action-doesn-t-stay-activated-td2308833.html
*/
private T verifyNewInstance(T t) {
if (t!=null && t.getDescriptor()!=this) {
// TODO: should this be a fatal error?
LOGGER.warning("Father of "+ t+" and its getDescriptor() points to two different instances. Probably malplaced @Extension. See http://hudson.361315.n4.nabble.com/Help-Hint-needed-Post-build-action-doesn-t-stay-activated-td2308833.html");
}
return t;
}
/**
* Returns the resource path to the help screen HTML, if any.
*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册