提交 e4c4b810 编写于 作者: O Oleg Nenashev

[FIXED JENKINS-44330] - Prevent classloading of Target comparator in LogRecorder#orderedTargets()

It is just a hotfix, there may be other LogRecorders affected. Ideally we need a response from Jetty maintainers to https://github.com/eclipse/jetty.project/issues/1563. No tests since I see no way to trigger such classloading + no actual need in it.
上级 d13b1361
......@@ -73,17 +73,14 @@ public class LogRecorder extends AbstractModelObject implements Saveable {
private volatile String name;
public final CopyOnWriteList<Target> targets = new CopyOnWriteList<Target>();
private final static TargetComparator TARGET_COMPARATOR = new TargetComparator();
@Restricted(NoExternalUse.class)
Target[] orderedTargets() {
// will contain targets ordered by reverse name length (place specific targets at the beginning)
Target[] ts = targets.toArray(new Target[]{});
Arrays.sort(ts, new Comparator<Target>() {
public int compare(Target left, Target right) {
return right.getName().length() - left.getName().length();
}
});
Arrays.sort(ts, TARGET_COMPARATOR);
return ts;
}
......@@ -206,6 +203,14 @@ public class LogRecorder extends AbstractModelObject implements Saveable {
}
}
private static class TargetComparator implements Comparator<Target> {
@Override
public int compare(Target left, Target right) {
return right.getName().length() - left.getName().length();
}
}
private static final class SetLevel extends MasterToSlaveCallable<Void,Error> {
/** known loggers (kept per agent), to avoid GC */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册