Skip to content

Commit

Permalink
[JENKINS-47779] comments addressed
Browse files Browse the repository at this point in the history
  • Loading branch information
escoem committed Nov 3, 2017
1 parent f27bdd1 commit 069fb03
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions src/main/java/com/cloudbees/jenkins/support/impl/AboutJenkins.java
Expand Up @@ -583,8 +583,7 @@ private static class AboutContent extends PrintedContent {
out.println("Active Plugins");
out.println("--------------");
out.println();
PluginManager pluginManager = jenkins.getPluginManager();
Iterable<PluginWrapper> plugins = getSorted(pluginManager.getPlugins());
Iterable<PluginWrapper> plugins = getPluginsSorted();
for (PluginWrapper w : plugins) {
if (w.isActive()) {
out.println(" * " + w.getShortName() + ":" + w.getVersion() + (w.hasUpdate()
Expand Down Expand Up @@ -704,8 +703,7 @@ public ActivePlugins(String path) {

@Override
protected void printTo(PrintWriter out) throws IOException {
PluginManager pluginManager = Helper.getActiveInstance().getPluginManager();
Iterable<PluginWrapper> plugins = getSorted(pluginManager.getPlugins());
Iterable<PluginWrapper> plugins = getPluginsSorted();
for (PluginWrapper w : plugins) {
if (w.isActive()) {
out.println(w.getShortName() + ":" + w.getVersion() + ":" + (w.isPinned() ? "pinned" : "not-pinned"));
Expand All @@ -721,8 +719,7 @@ public DisabledPlugins() {

@Override
protected void printTo(PrintWriter out) throws IOException {
PluginManager pluginManager = Helper.getActiveInstance().getPluginManager();
Iterable<PluginWrapper> plugins = getSorted(pluginManager.getPlugins());
Iterable<PluginWrapper> plugins = getPluginsSorted();
for (PluginWrapper w : plugins) {
if (!w.isActive()) {
out.println(w.getShortName() + ":" + w.getVersion() + ":" + (w.isPinned() ? "pinned" : "not-pinned"));
Expand Down Expand Up @@ -769,7 +766,7 @@ protected void printTo(PrintWriter out) throws IOException {

out.println("RUN mkdir -p /usr/share/jenkins/ref/plugins/");

Iterable<PluginWrapper> plugins = getSorted(pluginManager.getPlugins());
Iterable<PluginWrapper> plugins = getPluginsSorted(pluginManager);

List<PluginWrapper> activated = new ArrayList<PluginWrapper>();
List<PluginWrapper> disabled = new ArrayList<PluginWrapper>();
Expand Down Expand Up @@ -1010,11 +1007,20 @@ private class NodeChecksumsContent extends PrintedContent {
/**
* Fixes JENKINS-47779 caused by JENKINS-47713
* Not using SortedSet because of PluginWrapper doesn't implements equals and hashCode.
* @param list original list, probably an unmodifiableList
* @return new copy of the list sorted
* @return new copy of the PluginManager.getPlugins sorted
*/
private static Iterable<PluginWrapper> getSorted(List<PluginWrapper> list) {
final List<PluginWrapper> sorted = new LinkedList<PluginWrapper>(list);
private static Iterable<PluginWrapper> getPluginsSorted() {
PluginManager pluginManager = Helper.getActiveInstance().getPluginManager();
return getPluginsSorted(pluginManager);
}

private static Iterable<PluginWrapper> getPluginsSorted(PluginManager pluginManager) {
return listToSortedIterable(pluginManager.getPlugins());
}


private static <T extends Comparable<T>> Iterable<T> listToSortedIterable(List<T> list) {
final List<T> sorted = new LinkedList<T>(list);
Collections.sort(sorted);
return sorted;
}
Expand Down

0 comments on commit 069fb03

Please sign in to comment.