Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #2504 - expose more WebSocket details in jetty server dump #7058

Merged
merged 1 commit into from
Dec 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -238,5 +238,15 @@ public void customize(Configuration configurable)
if (maxOutgoingFrames != null)
configurable.setMaxOutgoingFrames(maxOutgoingFrames);
}

@Override
public String toString()
{
return String.format("%s@%x{idleTimeout=%s, writeTimeout=%s, autoFragment=%s, maxFrameSize=%s, " +
"inputBufferSize=%s, outputBufferSize=%s, maxBinaryMessageSize=%s, maxTextMessageSize=%s, maxOutgoingFrames=%s}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these numbers formatted with %s and not %d ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there's any major difference between %d and %s for integers unless you want some special formatting.

These are also class types and not the primitive ones, so I thought %s might be better, they are Duration, Boolean, Long, Integer and the values are null if no configuration is set for them.

getClass().getSimpleName(), hashCode(),
idleTimeout, writeTimeout, autoFragment, maxFrameSize, inputBufferSize, outputBufferSize,
maxBinaryMessageSize, maxTextMessageSize, maxOutgoingFrames);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,6 @@ public void lifeCycleStopping(LifeCycle context)
}
}

@Override
public String dump()
{
return Dumpable.dump(this);
}

@Override
public void dump(Appendable out, String indent) throws IOException
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ public void lifeCycleStopping(LifeCycle event)
contextHandler.removeBean(serverComponents);
contextHandler.removeEventListener(this);
}

@Override
public String toString()
{
return String.format("%sCleanupListener", WebSocketServerComponents.class.getSimpleName());
}
});

servletContext.setAttribute(WEBSOCKET_COMPONENTS_ATTRIBUTE, serverComponents);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

package org.eclipse.jetty.websocket.javax.common;

import java.io.IOException;
import java.time.Duration;
import java.util.ArrayList;
import java.util.HashSet;
Expand All @@ -26,13 +27,14 @@
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.util.DecoratedObjectFactory;
import org.eclipse.jetty.util.component.ContainerLifeCycle;
import org.eclipse.jetty.util.component.Dumpable;
import org.eclipse.jetty.websocket.core.Configuration;
import org.eclipse.jetty.websocket.core.WebSocketComponents;
import org.eclipse.jetty.websocket.core.WebSocketExtensionRegistry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public abstract class JavaxWebSocketContainer extends ContainerLifeCycle implements javax.websocket.WebSocketContainer
public abstract class JavaxWebSocketContainer extends ContainerLifeCycle implements javax.websocket.WebSocketContainer, Dumpable
{
private static final Logger LOG = LoggerFactory.getLogger(JavaxWebSocketContainer.class);
private final List<JavaxWebSocketSessionListener> sessionListeners = new ArrayList<>();
Expand Down Expand Up @@ -198,4 +200,10 @@ public void notifySessionListeners(Consumer<JavaxWebSocketSessionListener> consu
}
}
}

@Override
public void dump(Appendable out, String indent) throws IOException
{
Dumpable.dumpObjects(out, indent, this, defaultCustomizer);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ public void lifeCycleStopping(LifeCycle event)
contextHandler.removeEventListener(container);
contextHandler.removeEventListener(this);
}

@Override
public String toString()
{
return String.format("%sCleanupListener", JavaxWebSocketServerContainer.class.getSimpleName());
}
});

// Store a reference to the ServerContainer per - javax.websocket spec 1.0 final - section 6.4: Programmatic Server Deployment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.eclipse.jetty.http.pathmap.PathSpec;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.util.component.ContainerLifeCycle;
import org.eclipse.jetty.util.component.Dumpable;
import org.eclipse.jetty.util.component.LifeCycle;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.WebSocketBehavior;
Expand Down Expand Up @@ -94,6 +95,12 @@ public void lifeCycleStopping(LifeCycle event)
contextHandler.removeEventListener(container);
contextHandler.removeEventListener(this);
}

@Override
public String toString()
{
return String.format("%sCleanupListener", JettyWebSocketServerContainer.class.getSimpleName());
}
});

servletContext.setAttribute(JETTY_WEBSOCKET_CONTAINER_ATTRIBUTE, container);
Expand Down Expand Up @@ -306,4 +313,10 @@ public void setAutoFragment(boolean autoFragment)
{
customizer.setAutoFragment(autoFragment);
}

@Override
public void dump(Appendable out, String indent) throws IOException
{
Dumpable.dumpObjects(out, indent, this, customizer);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ public void lifeCycleStopping(LifeCycle event)
servletHandler.removeFilterMapping(mapping);
contextHandler.removeEventListener(this);
}

@Override
public String toString()
{
return String.format("%sCleanupListener", WebSocketUpgradeFilter.class.getSimpleName());
}
});

if (LOG.isDebugEnabled())
Expand Down Expand Up @@ -164,16 +170,10 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
chain.doFilter(request, response);
}

@Override
public String dump()
{
return Dumpable.dump(this);
}

@Override
public void dump(Appendable out, String indent) throws IOException
{
Dumpable.dumpObjects(out, indent, this, mappings);
Dumpable.dumpObjects(out, indent, this, defaultCustomizer, mappings);
}

@Override
Expand Down