Top Description Fields Constructors Methods
org.springframework.web.reactive.socket

public final Class CloseStatus

extends Object
Class Inheritance
Imports
java.util.Objects, org.springframework.lang.Nullable, org.springframework.util.Assert, .ObjectUtils, .StringUtils

Representation of WebSocket "close" status codes and reasons. Status codes in the 1xxx range are pre-defined by the protocol.
Author
Rossen Stoyanchev
Since
5.0
See Also
RFC 6455, Section 7.4.1 "Defined Status Codes"

Field Summary

Modifier and TypeField and Description
public static final CloseStatus
BAD_DATA

"1007 indicates that an endpoint is terminating the connection because it has received data within a message that was not consistent with the type of the message (e.g., non-UTF-8 [RFC3629] data within a text message)."

private final int
public static final CloseStatus
GOING_AWAY

"1001 indicates that an endpoint is "going away", such as a server going down or a browser having navigated away from a page."

public static final CloseStatus
NO_CLOSE_FRAME

"1006 is a reserved value and MUST NOT be set as a status code in a Close control frame by an endpoint.

public static final CloseStatus
NO_STATUS_CODE

"1005 is a reserved value and MUST NOT be set as a status code in a Close control frame by an endpoint.

public static final CloseStatus
NORMAL

"1000 indicates a normal closure, meaning that the purpose for which the connection was established has been fulfilled."

public static final CloseStatus
NOT_ACCEPTABLE

"1003 indicates that an endpoint is terminating the connection because it has received a type of data it cannot accept (e.g., an endpoint that understands only text data MAY send this if it receives a binary message)."

public static final CloseStatus
POLICY_VIOLATION

"1008 indicates that an endpoint is terminating the connection because it has received a message that violates its policy.

public static final CloseStatus
PROTOCOL_ERROR

"1002 indicates that an endpoint is terminating the connection due to a protocol error."

private final String
public static final CloseStatus
REQUIRED_EXTENSION

"1010 indicates that an endpoint (client) is terminating the connection because it has expected the server to negotiate one or more extension, but the server didn't return them in the response message of the WebSocket handshake.

public static final CloseStatus
SERVER_ERROR

"1011 indicates that a server is terminating the connection because it encountered an unexpected condition that prevented it from fulfilling the request."

public static final CloseStatus
SERVICE_OVERLOAD

"1013 indicates that the service is experiencing overload.

public static final CloseStatus
SERVICE_RESTARTED

"1012 indicates that the service is restarted.

public static final CloseStatus
TLS_HANDSHAKE_FAILURE

"1015 is a reserved value and MUST NOT be set as a status code in a Close control frame by an endpoint.

public static final CloseStatus
TOO_BIG_TO_PROCESS

"1009 indicates that an endpoint is terminating the connection because it has received a message that is too big for it to process."

Constructor Summary

AccessConstructor and Description
public
CloseStatus(int
the status code
code
)

Create a new CloseStatus instance.

public
CloseStatus(int
the status code
code
,
String
the reason
reason
)

Create a new CloseStatus instance.

Method Summary

Modifier and TypeMethod and Description
public static CloseStatus
create(int code, String reason)

Return a constant for the given code, or create a new instance if the code does not match or there is a reason.

public boolean
equals(Object
the reference object with which to compare.
other
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public boolean
equalsCode(CloseStatus other)
Deprecated as of 5.3 in favor of comparing codes directly

public int
getCode()

Return the status code.

public String
getReason()

Return the reason, or null if none.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public CloseStatus

Returns:

a new CloseStatus instance
withReason
(String
the reason
reason
)

Create a new CloseStatus from this one with the specified reason.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

BAD_DATAback to summary
public static final CloseStatus BAD_DATA

"1007 indicates that an endpoint is terminating the connection because it has received data within a message that was not consistent with the type of the message (e.g., non-UTF-8 [RFC3629] data within a text message)."

codeback to summary
private final int code
GOING_AWAYback to summary
public static final CloseStatus GOING_AWAY

"1001 indicates that an endpoint is "going away", such as a server going down or a browser having navigated away from a page."

NO_CLOSE_FRAMEback to summary
public static final CloseStatus NO_CLOSE_FRAME

"1006 is a reserved value and MUST NOT be set as a status code in a Close control frame by an endpoint. It is designated for use in applications expecting a status code to indicate that the connection was closed abnormally, e.g., without sending or receiving a Close control frame."

NO_STATUS_CODEback to summary
public static final CloseStatus NO_STATUS_CODE

"1005 is a reserved value and MUST NOT be set as a status code in a Close control frame by an endpoint. It is designated for use in applications expecting a status code to indicate that no status code was actually present."

NORMALback to summary
public static final CloseStatus NORMAL

"1000 indicates a normal closure, meaning that the purpose for which the connection was established has been fulfilled."

NOT_ACCEPTABLEback to summary
public static final CloseStatus NOT_ACCEPTABLE

"1003 indicates that an endpoint is terminating the connection because it has received a type of data it cannot accept (e.g., an endpoint that understands only text data MAY send this if it receives a binary message)."

POLICY_VIOLATIONback to summary
public static final CloseStatus POLICY_VIOLATION

"1008 indicates that an endpoint is terminating the connection because it has received a message that violates its policy. This is a generic status code that can be returned when there is no other more suitable status code (e.g., 1003 or 1009) or if there is a need to hide specific details about the policy."

PROTOCOL_ERRORback to summary
public static final CloseStatus PROTOCOL_ERROR

"1002 indicates that an endpoint is terminating the connection due to a protocol error."

reasonback to summary
private final String reason
Annotations
@Nullable
REQUIRED_EXTENSIONback to summary
public static final CloseStatus REQUIRED_EXTENSION

"1010 indicates that an endpoint (client) is terminating the connection because it has expected the server to negotiate one or more extension, but the server didn't return them in the response message of the WebSocket handshake. The list of extensions that are needed SHOULD appear in the /reason/ part of the Close frame. Note that this status code is not used by the server, because it can fail the WebSocket handshake instead."

SERVER_ERRORback to summary
public static final CloseStatus SERVER_ERROR

"1011 indicates that a server is terminating the connection because it encountered an unexpected condition that prevented it from fulfilling the request."

SERVICE_OVERLOADback to summary
public static final CloseStatus SERVICE_OVERLOAD

"1013 indicates that the service is experiencing overload. A client should only connect to a different IP (when there are multiple for the target) or reconnect to the same IP upon user action."

SERVICE_RESTARTEDback to summary
public static final CloseStatus SERVICE_RESTARTED

"1012 indicates that the service is restarted. A client may reconnect, and if it chooses to do, should reconnect using a randomized delay of 5 - 30s."

TLS_HANDSHAKE_FAILUREback to summary
public static final CloseStatus TLS_HANDSHAKE_FAILURE

"1015 is a reserved value and MUST NOT be set as a status code in a Close control frame by an endpoint. It is designated for use in applications expecting a status code to indicate that the connection was closed due to a failure to perform a TLS handshake (e.g., the server certificate can't be verified)."

TOO_BIG_TO_PROCESSback to summary
public static final CloseStatus TOO_BIG_TO_PROCESS

"1009 indicates that an endpoint is terminating the connection because it has received a message that is too big for it to process."

Constructor Detail

CloseStatusback to summary
public CloseStatus(int code)

Create a new CloseStatus instance.

Parameters
code:int

the status code

CloseStatusback to summary
public CloseStatus(int code, String reason)

Create a new CloseStatus instance.

Parameters
code:int

the status code

reason:String

the reason

Method Detail

createback to summary
public static CloseStatus create(int code, String reason)

Return a constant for the given code, or create a new instance if the code does not match or there is a reason.

Since
5.3
equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
other:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
equalsCodeback to summary
public boolean equalsCode(CloseStatus other)

Deprecated

as of 5.3 in favor of comparing codes directly

Annotations
@Deprecated
getCodeback to summary
public int getCode()

Return the status code.

getReasonback to summary
public String getReason()

Return the reason, or null if none.

Annotations
@Nullable
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
withReasonback to summary
public CloseStatus withReason(String reason)

Create a new CloseStatus from this one with the specified reason.

Parameters
reason:String

the reason

Returns:CloseStatus

a new CloseStatus instance