diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/ManagedSelector.java b/jetty-io/src/main/java/org/eclipse/jetty/io/ManagedSelector.java index 0346f4c10e5..f2ffc393fea 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/ManagedSelector.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/ManagedSelector.java @@ -28,6 +28,7 @@ import java.nio.channels.SelectionKey; import java.nio.channels.Selector; import java.util.ArrayDeque; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.Iterator; import java.util.List; @@ -40,6 +41,7 @@ import java.util.concurrent.atomic.AtomicBoolean; import org.eclipse.jetty.util.component.ContainerLifeCycle; import org.eclipse.jetty.util.component.Dumpable; +import org.eclipse.jetty.util.component.DumpableCollection; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.util.thread.ExecutionStrategy; @@ -226,29 +228,23 @@ public class ManagedSelector extends ContainerLifeCycle implements Dumpable } } - @Override - public String dump() - { - super.dump(); - return ContainerLifeCycle.dump(this); - } - @Override public void dump(Appendable out, String indent) throws IOException { + super.dump(out, indent); Selector selector = _selector; - if (selector == null || !selector.isOpen()) - dumpBeans(out, indent); - else + if (selector != null && selector.isOpen()) { - final ArrayList dump = new ArrayList<>(selector.keys().size() * 2); - DumpKeys dumpKeys = new DumpKeys(dump); + List actions; + try (Locker.Lock lock = _locker.lock()) + { + actions = new ArrayList<>(_actions); + } + List keys = new ArrayList<>(selector.keys().size()); + DumpKeys dumpKeys = new DumpKeys(keys); submit(dumpKeys); dumpKeys.await(5, TimeUnit.SECONDS); - if (dump.isEmpty()) - dumpBeans(out, indent); - else - dumpBeans(out, indent, dump); + dump(out, indent, Arrays.asList(new DumpableCollection("keys", keys), new DumpableCollection("actions", actions))); } } @@ -512,7 +508,7 @@ public class ManagedSelector extends ContainerLifeCycle implements Dumpable } catch (Throwable x) { - _dumps.add(String.format("SelectionKey@%x[%s]", key.hashCode(), x)); + _dumps.add(String.format("SelectionKey@%x[%s]->%s", key.hashCode(), x, key.attachment())); } } } diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/component/ContainerLifeCycle.java b/jetty-util/src/main/java/org/eclipse/jetty/util/component/ContainerLifeCycle.java index 5c9d177daf1..7ffc20bedab 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/component/ContainerLifeCycle.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/component/ContainerLifeCycle.java @@ -660,13 +660,10 @@ public class ContainerLifeCycle extends AbstractLifeCycle implements Container, int size = _beans.size(); for (Collection c : collections) size += c.size(); - if (size == 0) - return; int i = 0; for (Bean b : _beans) { - i++; - + ++i; switch(b._managed) { case POJO: @@ -697,20 +694,15 @@ public class ContainerLifeCycle extends AbstractLifeCycle implements Container, else dumpObject(out, b._bean); break; - } } - if (i c : collections) { for (Object o : c) { i++; out.append(indent).append(" +> "); - if (o instanceof Dumpable) ((Dumpable)o).dump(out, indent + (i == size ? " " : " | ")); else