From 3f1c555052a8ade6043abdc3303647cf5c06eadb Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Sun, 24 Sep 2023 07:38:48 -0700 Subject: [PATCH] Fix compilation error with `maven.compiler.release=21` (#8520) --- core/src/main/java/hudson/tasks/Publisher.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/hudson/tasks/Publisher.java b/core/src/main/java/hudson/tasks/Publisher.java index 1b798e5b3813..e486dc8c541a 100644 --- a/core/src/main/java/hudson/tasks/Publisher.java +++ b/core/src/main/java/hudson/tasks/Publisher.java @@ -130,10 +130,7 @@ public Descriptor getDescriptor() { * * @see DescriptorExtensionList#createDescriptorList(hudson.model.Hudson, Class) */ - @SuppressFBWarnings(value = "SE_COMPARATOR_SHOULD_BE_SERIALIZABLE", justification = "Since the publisher is not Serializable, " + - "no need for the Comparator") - public static final class DescriptorExtensionListImpl extends DescriptorExtensionList> - implements Comparator>> { + public static final class DescriptorExtensionListImpl extends DescriptorExtensionList> { public DescriptorExtensionListImpl(Jenkins hudson) { super(hudson, Publisher.class); @@ -142,10 +139,14 @@ public DescriptorExtensionListImpl(Jenkins hudson) { @Override protected List>> sort(List>> r) { List>> copy = new ArrayList<>(r); - copy.sort(this); + copy.sort(new ExtensionComponentComparator()); return copy; } + } + @SuppressFBWarnings(value = "SE_COMPARATOR_SHOULD_BE_SERIALIZABLE", justification = "Since the publisher is not Serializable, " + + "no need for the Comparator") + private static final class ExtensionComponentComparator implements Comparator>> { @Override public int compare(ExtensionComponent> lhs, ExtensionComponent> rhs) { int r = classify(lhs.getInstance()) - classify(rhs.getInstance());