[FIXED - 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 No tests since I see no way to trigger such classloading + no actual need in it.
@@ -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;
}
@@ -207,6 +204,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 */
@SuppressWarnings("MismatchedQueryAndUpdateOfCollection") private static final Set<Logger> loggers = new HashSet<Logger>();
