Skip to content

Commit

Permalink
Fix for an issue where Jenkins instantiates the plugin without popula…
Browse files Browse the repository at this point in the history
…ting its private fields during object construction.

The issue manifests itself with a 500 internal server error page being displayed after upgrading the plugin to build.70

Closes #43
  • Loading branch information
jan-molak committed Feb 26, 2014
1 parent 62745f3 commit f75a2fe
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,14 @@ protected void submit(StaplerRequest req) throws ServletException, IOException,
}
}

// defensive coding to avoid issues when Jenkins instantiates the plugin without populating its fields
// https://github.com/jan-molak/jenkins-build-monitor-plugin/issues/43
private Comparator<AbstractProject> currentOrderOrDefault() {
return order == null ? new ByName() : order;
}

public String currentOrder() {
return order.getClass().getSimpleName();
return currentOrderOrDefault().getClass().getSimpleName();
}

private Comparator<AbstractProject> order = new ByName();
Expand Down Expand Up @@ -147,7 +153,7 @@ private List<JobView> jobViews() {
List<AbstractProject> projects = filter(super.getItems(), AbstractProject.class);
List<JobView> jobs = new ArrayList<JobView>();

Collections.sort(projects, order);
Collections.sort(projects, currentOrderOrDefault());

for (AbstractProject project : projects) {
jobs.add(JobView.of(project, withAugmentationsIfTheyArePresent()));
Expand Down

0 comments on commit f75a2fe

Please sign in to comment.