Skip to content

Commit

Permalink
[JENKINS-40828] Fix some NPEs found when using downstream
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenc committed Jan 6, 2017
1 parent 9acd212 commit 0733fe6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/test/java/jenkins/scm/impl/mock/MockSCMNavigator.java
Expand Up @@ -99,13 +99,13 @@ protected String id() {

@Override
public void visitSources(@NonNull SCMSourceObserver observer) throws IOException, InterruptedException {
controller.checkFaults(null, null, null, false);
controller().checkFaults(null, null, null, false);
for (String name : controller().listRepositories()) {
if (!observer.isObserving()) {
return;
}
checkInterrupt();
controller.checkFaults(name, null, null, false);
controller().checkFaults(name, null, null, false);
SCMSourceObserver.ProjectObserver po = observer.observe(name);
po.addSource(new MockSCMSource(getId() + "::" + name,
controller, name, includeBranches, includeTags, includeChangeRequests));
Expand All @@ -119,7 +119,7 @@ public List<Action> retrieveActions(@NonNull SCMNavigatorOwner owner,
@CheckForNull SCMNavigatorEvent event,
@NonNull TaskListener listener)
throws IOException, InterruptedException {
controller.checkFaults(null, null, null, true);
controller().checkFaults(null, null, null, true);
List<Action> result = new ArrayList<Action>();
result.add(new MockSCMLink("organization"));
String description = controller().getDescription();
Expand Down
20 changes: 10 additions & 10 deletions src/test/java/jenkins/scm/impl/mock/MockSCMSource.java
Expand Up @@ -118,19 +118,19 @@ public boolean isIncludeChangeRequests() {
protected void retrieve(@CheckForNull SCMSourceCriteria criteria, @NonNull SCMHeadObserver observer,
@CheckForNull SCMHeadEvent<?> event, @NonNull TaskListener listener)
throws IOException, InterruptedException {
controller.checkFaults(repository, null, null, false);
controller().checkFaults(repository, null, null, false);
Set<SCMHead> includes = observer.getIncludes();
if (includeBranches) {
for (final String branch : controller().listBranches(repository)) {
checkInterrupt();
String revision = controller().getRevision(repository, branch);
MockSCMHead head = new MockSCMHead(branch);
controller.checkFaults(repository, head.getName(), null, false);
controller().checkFaults(repository, head.getName(), null, false);
if (includes != null && !includes.contains(head)) {
continue;
}
if (criteria == null || criteria.isHead(new MockSCMProbe(head, revision), listener)) {
controller.checkFaults(repository, head.getName(), revision, false);
controller().checkFaults(repository, head.getName(), revision, false);
observer.observe(head, new MockSCMRevision(head, revision));
}
}
Expand All @@ -140,12 +140,12 @@ protected void retrieve(@CheckForNull SCMSourceCriteria criteria, @NonNull SCMHe
checkInterrupt();
String revision = controller().getRevision(repository, tag);
MockSCMHead head = new MockTagSCMHead(tag, controller().getTagTimestamp(repository, tag));
controller.checkFaults(repository, head.getName(), null, false);
controller().checkFaults(repository, head.getName(), null, false);
if (includes != null && !includes.contains(head)) {
continue;
}
if (criteria == null || criteria.isHead(new MockSCMProbe(head, revision), listener)) {
controller.checkFaults(repository, head.getName(), revision, false);
controller().checkFaults(repository, head.getName(), revision, false);
observer.observe(head, new MockSCMRevision(head, revision));
}
}
Expand All @@ -156,12 +156,12 @@ protected void retrieve(@CheckForNull SCMSourceCriteria criteria, @NonNull SCMHe
String revision = controller().getRevision(repository, "change-request/" + number);
String target = controller().getTarget(repository, number);
MockChangeRequestSCMHead head = new MockChangeRequestSCMHead(number, target);
controller.checkFaults(repository, head.getName(), null, false);
controller().checkFaults(repository, head.getName(), null, false);
if (includes != null && !includes.contains(head)) {
continue;
}
if (criteria == null || criteria.isHead(new MockSCMProbe(head, revision), listener)) {
controller.checkFaults(repository, head.getName(), revision, false);
controller().checkFaults(repository, head.getName(), revision, false);
observer.observe(head, new MockSCMRevision(head, revision));
}
}
Expand All @@ -179,7 +179,7 @@ public SCM build(@NonNull SCMHead head, @CheckForNull SCMRevision revision) {
@Override
protected List<Action> retrieveActions(@CheckForNull SCMSourceEvent event, @NonNull TaskListener listener)
throws IOException, InterruptedException {
controller.checkFaults(repository, null, null, true);
controller().checkFaults(repository, null, null, true);
List<Action> result = new ArrayList<Action>();
result.add(new MockSCMLink("source"));
String description = controller().getDescription(repository);
Expand All @@ -201,7 +201,7 @@ protected List<Action> retrieveActions(@NonNull SCMRevision revision,
@CheckForNull SCMHeadEvent event,
@NonNull TaskListener listener)
throws IOException, InterruptedException {
controller.checkFaults(repository, revision.getHead().getName(), ((MockSCMRevision)revision).getHash(), true);
controller().checkFaults(repository, revision.getHead().getName(), ((MockSCMRevision)revision).getHash(), true);
return Collections.<Action>singletonList(new MockSCMLink("revision"));
}

Expand All @@ -211,7 +211,7 @@ protected List<Action> retrieveActions(@NonNull SCMHead head,
@CheckForNull SCMHeadEvent event,
@NonNull TaskListener listener)
throws IOException, InterruptedException {
controller.checkFaults(repository, head.getName(), null, true);
controller().checkFaults(repository, head.getName(), null, true);
List<Action> result = new ArrayList<Action>();
if (head instanceof MockChangeRequestSCMHead) {
result.add(new ContributorMetadataAction(
Expand Down

0 comments on commit 0733fe6

Please sign in to comment.