mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-17 05:52:26 +00:00
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 git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@33544 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
5670006ddf
commit
a30ee8291d
1 file changed
+15
-3
@@ -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.
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user