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

Jetty WebSocket API minor cleanups before Jetty-10 full release #5235

Merged
merged 4 commits into from
Sep 9, 2020
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 @@ -16,12 +16,14 @@
// ========================================================================
//

import org.eclipse.jetty.websocket.api.ExtensionConfig;

module org.eclipse.jetty.websocket.jetty.api
{
exports org.eclipse.jetty.websocket.api;
exports org.eclipse.jetty.websocket.api.annotations;
exports org.eclipse.jetty.websocket.api.extensions;
exports org.eclipse.jetty.websocket.api.exceptions;
exports org.eclipse.jetty.websocket.api.util;

uses org.eclipse.jetty.websocket.api.extensions.ExtensionConfig.Parser;
uses ExtensionConfig.Parser;
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public class CloseStatus
private static final int MAX_CONTROL_PAYLOAD = 125;
public static final int MAX_REASON_PHRASE = MAX_CONTROL_PAYLOAD - 2;

private int code;
private String phrase;
private final int code;
private final String phrase;

/**
* Creates a reason for closing a web socket connection with the given code and reason phrase.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// ========================================================================
//

package org.eclipse.jetty.websocket.api.extensions;
package org.eclipse.jetty.websocket.api;

import java.util.Map;
import java.util.ServiceLoader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static Type from(byte op)
throw new IllegalArgumentException("OpCode " + op + " is not a valid Frame.Type");
}

private byte opcode;
private final byte opcode;

Type(byte code)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
import java.util.List;
import java.util.Map;

import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;

/**
* The HTTP Upgrade to WebSocket Request
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
import java.util.Map;
import java.util.Set;

import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;

/**
* The HTTP Upgrade to WebSocket Response
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,12 @@ public Session getSession()

public boolean isConnected()
{
Session sess = this.session;
return (sess != null) && (sess.isOpen());
return session.isOpen();
}

public boolean isNotConnected()
{
Session sess = this.session;
return (sess == null) || (!sess.isOpen());
return !isConnected();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
// ========================================================================
//

package org.eclipse.jetty.websocket.api;
package org.eclipse.jetty.websocket.api.exceptions;

import org.eclipse.jetty.websocket.api.StatusCode;

/**
* Exception to terminate the connection because it has received data within a frame payload that was not consistent with the requirements of that frame
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
// ========================================================================
//

package org.eclipse.jetty.websocket.api;
package org.eclipse.jetty.websocket.api.exceptions;

@SuppressWarnings("serial")
public class CloseException extends WebSocketException
{
private int statusCode;
private final int statusCode;

public CloseException(int closeCode, String message)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
// ========================================================================
//

package org.eclipse.jetty.websocket.api;
package org.eclipse.jetty.websocket.api.exceptions;

import org.eclipse.jetty.websocket.api.WebSocketAdapter;
import org.eclipse.jetty.websocket.api.WebSocketListener;
import org.eclipse.jetty.websocket.api.annotations.WebSocket;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
// ========================================================================
//

package org.eclipse.jetty.websocket.api;
package org.eclipse.jetty.websocket.api.exceptions;

import org.eclipse.jetty.websocket.api.StatusCode;

/**
* Exception when a message is too large for the internal buffers occurs and should trigger a connection close.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
// ========================================================================
//

package org.eclipse.jetty.websocket.api;
package org.eclipse.jetty.websocket.api.exceptions;

import org.eclipse.jetty.websocket.api.StatusCode;

/**
* Exception when a violation of policy occurs and should trigger a connection close.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
// ========================================================================
//

package org.eclipse.jetty.websocket.api;
package org.eclipse.jetty.websocket.api.exceptions;

import org.eclipse.jetty.websocket.api.StatusCode;

/**
* Per spec, a protocol error should result in a Close frame of status code 1002 (PROTOCOL_ERROR)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// ========================================================================
//

package org.eclipse.jetty.websocket.api;
package org.eclipse.jetty.websocket.api.exceptions;

import java.net.URI;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// ========================================================================
//

package org.eclipse.jetty.websocket.api;
package org.eclipse.jetty.websocket.api.exceptions;

/**
* A recoverable exception within the websocket framework.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// ========================================================================
//

package org.eclipse.jetty.websocket.api;
package org.eclipse.jetty.websocket.api.exceptions;

/**
* Exception thrown to indicate a connection I/O timeout.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
//

/**
* Jetty WebSocket API : WebSocket Extension API
* Jetty WebSocket API : Exception Types
*/
package org.eclipse.jetty.websocket.api.extensions;
package org.eclipse.jetty.websocket.api.exceptions;

Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
import java.net.URISyntaxException;
import java.util.Objects;

// @checkstyle-disable-check : AbbreviationAsWordInNameCheck

/**
* Utility methods for converting a {@link URI} between a HTTP(S) and WS(S) URI.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// ========================================================================
//

package org.eclipse.jetty.websocket.api;
package org.eclipse.jetty.websocket.api.util;

public final class WebSocketConstants
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@

import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpScheme;
import org.eclipse.jetty.websocket.api.ExtensionConfig;
import org.eclipse.jetty.websocket.api.UpgradeRequest;
import org.eclipse.jetty.websocket.api.UpgradeResponse;
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;

/**
* Client based UpgradeRequest API
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.util.MultiMap;
import org.eclipse.jetty.util.UrlEncoded;
import org.eclipse.jetty.websocket.api.ExtensionConfig;
import org.eclipse.jetty.websocket.api.UpgradeRequest;
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
import org.eclipse.jetty.websocket.core.client.CoreClientUpgradeRequest;

import static java.nio.charset.StandardCharsets.UTF_8;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@

import org.eclipse.jetty.client.HttpResponse;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.websocket.api.ExtensionConfig;
import org.eclipse.jetty.websocket.api.UpgradeResponse;
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;

/**
* Representing the Jetty {@link org.eclipse.jetty.client.HttpClient}'s {@link org.eclipse.jetty.client.HttpResponse}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// ========================================================================
//

import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
import org.eclipse.jetty.websocket.api.ExtensionConfig;
import org.eclipse.jetty.websocket.common.ExtensionConfigParser;

module org.eclipse.jetty.websocket.jetty.common
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import org.eclipse.jetty.websocket.core.ExtensionConfig;

public class ExtensionConfigParser implements org.eclipse.jetty.websocket.api.extensions.ExtensionConfig.Parser
public class ExtensionConfigParser implements org.eclipse.jetty.websocket.api.ExtensionConfig.Parser
{
/**
* Parse a single parameterized name.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/**
* Represents an Extension Configuration, as seen during the connection Handshake process.
*/
public class JettyExtensionConfig implements org.eclipse.jetty.websocket.api.extensions.ExtensionConfig
public class JettyExtensionConfig implements org.eclipse.jetty.websocket.api.ExtensionConfig
{

private final ExtensionConfig config;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -507,27 +507,27 @@ private void demand()
public static Throwable convertCause(Throwable cause)
{
if (cause instanceof MessageTooLargeException)
return new org.eclipse.jetty.websocket.api.MessageTooLargeException(cause.getMessage(), cause);
return new org.eclipse.jetty.websocket.api.exceptions.MessageTooLargeException(cause.getMessage(), cause);

if (cause instanceof ProtocolException)
return new org.eclipse.jetty.websocket.api.ProtocolException(cause.getMessage(), cause);
return new org.eclipse.jetty.websocket.api.exceptions.ProtocolException(cause.getMessage(), cause);

if (cause instanceof BadPayloadException)
return new org.eclipse.jetty.websocket.api.BadPayloadException(cause.getMessage(), cause);
return new org.eclipse.jetty.websocket.api.exceptions.BadPayloadException(cause.getMessage(), cause);

if (cause instanceof CloseException)
return new org.eclipse.jetty.websocket.api.CloseException(((CloseException)cause).getStatusCode(), cause.getMessage(), cause);
return new org.eclipse.jetty.websocket.api.exceptions.CloseException(((CloseException)cause).getStatusCode(), cause.getMessage(), cause);

if (cause instanceof WebSocketTimeoutException)
return new org.eclipse.jetty.websocket.api.WebSocketTimeoutException(cause.getMessage(), cause);
return new org.eclipse.jetty.websocket.api.exceptions.WebSocketTimeoutException(cause.getMessage(), cause);

if (cause instanceof InvalidSignatureException)
return new org.eclipse.jetty.websocket.api.InvalidWebSocketException(cause.getMessage(), cause);
return new org.eclipse.jetty.websocket.api.exceptions.InvalidWebSocketException(cause.getMessage(), cause);

if (cause instanceof UpgradeException)
{
UpgradeException ue = (UpgradeException)cause;
return new org.eclipse.jetty.websocket.api.UpgradeException(ue.getRequestURI(), ue.getResponseStatusCode(), cause);
return new org.eclipse.jetty.websocket.api.exceptions.UpgradeException(ue.getRequestURI(), ue.getResponseStatusCode(), cause);
}

return cause;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.lang.invoke.MethodHandle;

import org.eclipse.jetty.websocket.api.BatchMode;
import org.eclipse.jetty.websocket.api.InvalidWebSocketException;
import org.eclipse.jetty.websocket.api.exceptions.InvalidWebSocketException;
import org.eclipse.jetty.websocket.core.Configuration;
import org.eclipse.jetty.websocket.util.messages.MessageSink;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

package org.eclipse.jetty.websocket.common;

import org.eclipse.jetty.websocket.api.InvalidWebSocketException;
import org.eclipse.jetty.websocket.api.exceptions.InvalidWebSocketException;
import org.eclipse.jetty.websocket.util.DuplicateAnnotationException;
import org.eclipse.jetty.websocket.util.InvalidSignatureException;
import org.eclipse.jetty.websocket.util.messages.ByteArrayMessageSink;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
import java.io.IOException;
import java.util.List;

import org.eclipse.jetty.websocket.api.ExtensionConfig;
import org.eclipse.jetty.websocket.api.UpgradeRequest;
import org.eclipse.jetty.websocket.api.UpgradeResponse;
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;

public interface JettyServerUpgradeResponse extends UpgradeResponse
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public void addMapping(String pathSpec, final Class<?> endpointClass)
}
catch (Exception e)
{
throw new org.eclipse.jetty.websocket.api.WebSocketException("Unable to create instance of " + endpointClass.getName(), e);
throw new org.eclipse.jetty.websocket.api.exceptions.WebSocketException("Unable to create instance of " + endpointClass.getName(), e);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
import org.eclipse.jetty.websocket.api.ExtensionConfig;
import org.eclipse.jetty.websocket.common.JettyExtensionConfig;
import org.eclipse.jetty.websocket.server.JettyServerUpgradeRequest;
import org.eclipse.jetty.websocket.util.server.internal.ServerUpgradeRequest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import java.util.Set;
import java.util.stream.Collectors;

import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
import org.eclipse.jetty.websocket.api.ExtensionConfig;
import org.eclipse.jetty.websocket.common.JettyExtensionConfig;
import org.eclipse.jetty.websocket.server.JettyServerUpgradeResponse;
import org.eclipse.jetty.websocket.util.server.internal.ServerUpgradeResponse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.eclipse.jetty.util.resource.PathResource;
import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
import org.eclipse.jetty.websocket.api.ExtensionConfig;
import org.eclipse.jetty.websocket.server.JettyServerUpgradeRequest;
import org.eclipse.jetty.websocket.server.JettyServerUpgradeResponse;
import org.eclipse.jetty.websocket.server.JettyWebSocketCreator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.websocket.api.ExtensionConfig;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
import org.eclipse.jetty.websocket.client.ClientUpgradeRequest;
import org.eclipse.jetty.websocket.client.JettyUpgradeListener;
import org.eclipse.jetty.websocket.client.WebSocketClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.StatusCode;
import org.eclipse.jetty.websocket.api.UpgradeException;
import org.eclipse.jetty.websocket.api.exceptions.UpgradeException;
import org.eclipse.jetty.websocket.client.WebSocketClient;
import org.eclipse.jetty.websocket.server.JettyWebSocketServlet;
import org.eclipse.jetty.websocket.server.JettyWebSocketServletFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.util.BlockingArrayQueue;
import org.eclipse.jetty.websocket.api.Frame;
import org.eclipse.jetty.websocket.api.MessageTooLargeException;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.StatusCode;
import org.eclipse.jetty.websocket.api.WebSocketFrameListener;
import org.eclipse.jetty.websocket.api.WebSocketListener;
import org.eclipse.jetty.websocket.api.WebSocketTimeoutException;
import org.eclipse.jetty.websocket.api.exceptions.MessageTooLargeException;
import org.eclipse.jetty.websocket.api.exceptions.WebSocketTimeoutException;
import org.eclipse.jetty.websocket.api.util.WSURI;
import org.eclipse.jetty.websocket.client.WebSocketClient;
import org.eclipse.jetty.websocket.core.CloseStatus;
Expand Down
Loading