Skip to content
Permalink
Browse files
[JENKINS-47779] copy list before sorting
  • Loading branch information
escoem committed Nov 3, 2017
1 parent 9fc6229 commit f27bdd1c6ec8b8869526fb34ece86e689f46f492
Showing with 16 additions and 8 deletions.
  1. +16 −8 src/main/java/com/cloudbees/jenkins/support/impl/AboutJenkins.java
@@ -62,6 +62,7 @@
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -583,8 +584,7 @@ public synchronized int n() {
out.println("--------------");
out.println();
PluginManager pluginManager = jenkins.getPluginManager();
List<PluginWrapper> plugins = new ArrayList<PluginWrapper>(pluginManager.getPlugins());
Collections.sort(plugins);
Iterable<PluginWrapper> plugins = getSorted(pluginManager.getPlugins());
for (PluginWrapper w : plugins) {
if (w.isActive()) {
out.println(" * " + w.getShortName() + ":" + w.getVersion() + (w.hasUpdate()
@@ -705,8 +705,7 @@ public ActivePlugins(String path) {
@Override
protected void printTo(PrintWriter out) throws IOException {
PluginManager pluginManager = Helper.getActiveInstance().getPluginManager();
List<PluginWrapper> plugins = pluginManager.getPlugins();
Collections.sort(plugins);
Iterable<PluginWrapper> plugins = getSorted(pluginManager.getPlugins());
for (PluginWrapper w : plugins) {
if (w.isActive()) {
out.println(w.getShortName() + ":" + w.getVersion() + ":" + (w.isPinned() ? "pinned" : "not-pinned"));
@@ -723,8 +722,7 @@ public DisabledPlugins() {
@Override
protected void printTo(PrintWriter out) throws IOException {
PluginManager pluginManager = Helper.getActiveInstance().getPluginManager();
List<PluginWrapper> plugins = pluginManager.getPlugins();
Collections.sort(plugins);
Iterable<PluginWrapper> plugins = getSorted(pluginManager.getPlugins());
for (PluginWrapper w : plugins) {
if (!w.isActive()) {
out.println(w.getShortName() + ":" + w.getVersion() + ":" + (w.isPinned() ? "pinned" : "not-pinned"));
@@ -771,8 +769,7 @@ protected void printTo(PrintWriter out) throws IOException {

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

List<PluginWrapper> plugins = pluginManager.getPlugins();
Collections.sort(plugins);
Iterable<PluginWrapper> plugins = getSorted(pluginManager.getPlugins());

List<PluginWrapper> activated = new ArrayList<PluginWrapper>();
List<PluginWrapper> disabled = new ArrayList<PluginWrapper>();
@@ -1010,4 +1007,15 @@ private String getLabelString(Node n) {
}
}

/**
* 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
*/
private static Iterable<PluginWrapper> getSorted(List<PluginWrapper> list) {
final List<PluginWrapper> sorted = new LinkedList<PluginWrapper>(list);
Collections.sort(sorted);
return sorted;
}
}

0 comments on commit f27bdd1

Please sign in to comment.