Skip to content
Permalink
Browse files

[JENKINS-43507] Document that overriders must invoke the parent

(If they don't we could get class cast exceptions)
  • Loading branch information...
stephenc committed Jun 14, 2017
1 parent 1250284 commit 0b6a184e37bfc552b4636a13d94639e1756bc53f
Showing with 7 additions and 0 deletions.
  1. +7 −0 src/main/java/jenkins/scm/api/trait/SCMHeadAuthorityDescriptor.java
@@ -25,6 +25,7 @@
package jenkins.scm.api.trait;

import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.OverrideMustInvoke;
import hudson.model.Descriptor;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
@@ -115,6 +116,7 @@ protected SCMHeadAuthorityDescriptor() {
* @param head the {@link SCMHead}.
* @return {@code true} if applicable.
*/
@OverrideMustInvoke
public boolean isApplicableToHead(@NonNull SCMHead head) {
return isApplicableToHead(head.getClass()) && isApplicableToOrigin(head.getOrigin());
}
@@ -125,6 +127,7 @@ public boolean isApplicableToHead(@NonNull SCMHead head) {
* @param headClass the type of {@link SCMHead}.
* @return {@code true} if applicable.
*/
@OverrideMustInvoke
public boolean isApplicableToHead(@NonNull Class<? extends SCMHeadMixin> headClass) {
return this.headClass.isAssignableFrom(headClass);
}
@@ -135,6 +138,7 @@ public boolean isApplicableToHead(@NonNull Class<? extends SCMHeadMixin> headCla
* @param revision the {@link SCMRevision}.
* @return {@code true} if applicable.
*/
@OverrideMustInvoke
public boolean isApplicableToRevision(@NonNull SCMRevision revision) {
return isApplicableToHead(revision.getHead()) && isApplicableToRevision(revision.getClass());
}
@@ -145,6 +149,7 @@ public boolean isApplicableToRevision(@NonNull SCMRevision revision) {
* @param revisionClass the type of {@link SCMRevision}.
* @return {@code true} if applicable.
*/
@OverrideMustInvoke
public boolean isApplicableToRevision(@NonNull Class<? extends SCMRevision> revisionClass) {
return this.revisionClass.isAssignableFrom(revisionClass);
}
@@ -155,6 +160,7 @@ public boolean isApplicableToRevision(@NonNull Class<? extends SCMRevision> revi
* @param request the {@link SCMSourceRequest}.
* @return {@code true} if applicable.
*/
@OverrideMustInvoke
public boolean isApplicableToRequest(@NonNull SCMSourceRequest request) {
return requestClass.isInstance(request);
}
@@ -165,6 +171,7 @@ public boolean isApplicableToRequest(@NonNull SCMSourceRequest request) {
* @param requestClass the type of {@link SCMSourceRequest}.
* @return {@code true} if applicable.
*/
@OverrideMustInvoke
public boolean isApplicableToRequest(@NonNull Class<? extends SCMSourceRequest> requestClass) {
return this.requestClass.isAssignableFrom(requestClass);
}

0 comments on commit 0b6a184

Please sign in to comment.
You can’t perform that action at this time.