Remove APIs marked as deprecated for removal

Closes gh-33809
This commit is contained in:
Juergen Hoeller
2024-12-04 13:19:39 +01:00
parent 078d683f47
commit 2b9010c2a2
150 changed files with 141 additions and 5922 deletions

View File

@@ -105,28 +105,6 @@ public abstract class AbstractWebSocketClient implements WebSocketClient {
}
}
/**
* Perform the actual handshake to establish a connection to the server.
* @param webSocketHandler the client-side handler for WebSocket messages
* @param headers the HTTP headers to use for the handshake, with unwanted (forbidden)
* headers filtered out (never {@code null})
* @param uri the target URI for the handshake (never {@code null})
* @param subProtocols requested sub-protocols, or an empty list
* @param extensions requested WebSocket extensions, or an empty list
* @param attributes the attributes to associate with the WebSocketSession, i.e. via
* {@link WebSocketSession#getAttributes()}; currently always an empty map.
* @return the established WebSocket session wrapped in a {@code ListenableFuture}.
* @deprecated as of 6.0, in favor of {@link #executeInternal(WebSocketHandler, HttpHeaders, URI, List, List, Map)}
*/
@Deprecated(since = "6.0", forRemoval = true)
@SuppressWarnings("removal")
protected org.springframework.util.concurrent.ListenableFuture<WebSocketSession> doHandshakeInternal(
WebSocketHandler webSocketHandler, HttpHeaders headers, URI uri, List<String> subProtocols,
List<WebSocketExtension> extensions, Map<String, Object> attributes) {
throw new UnsupportedOperationException("doHandshakeInternal is deprecated in favor of executeInternal");
}
/**
* Perform the actual handshake to establish a connection to the server.
* @param webSocketHandler the client-side handler for WebSocket messages

View File

@@ -35,24 +35,6 @@ import org.springframework.web.socket.WebSocketSession;
*/
public interface WebSocketClient {
/**
* Execute a handshake request to the given url and handle the resulting
* WebSocket session with the given handler.
* @param webSocketHandler the session handler
* @param uriTemplate the url template
* @param uriVariables the variables to expand the template
* @return a future that completes when the session is available
* @deprecated as of 6.0, in favor of {@link #execute(WebSocketHandler, String, Object...)}
*/
@Deprecated(since = "6.0", forRemoval = true)
@SuppressWarnings("removal")
default org.springframework.util.concurrent.ListenableFuture<WebSocketSession> doHandshake(
WebSocketHandler webSocketHandler, String uriTemplate, Object... uriVariables) {
return new org.springframework.util.concurrent.CompletableToListenableFutureAdapter<>(
execute(webSocketHandler, uriTemplate, uriVariables));
}
/**
* Execute a handshake request to the given url and handle the resulting
* WebSocket session with the given handler.
@@ -65,23 +47,6 @@ public interface WebSocketClient {
CompletableFuture<WebSocketSession> execute(WebSocketHandler webSocketHandler,
String uriTemplate, Object... uriVariables);
/**
* Execute a handshake request to the given url and handle the resulting
* WebSocket session with the given handler.
* @param webSocketHandler the session handler
* @param uri the url
* @return a future that completes when the session is available
* @deprecated as of 6.0, in favor of {@link #execute(WebSocketHandler, WebSocketHttpHeaders, URI)}
*/
@Deprecated(since = "6.0", forRemoval = true)
@SuppressWarnings("removal")
default org.springframework.util.concurrent.ListenableFuture<WebSocketSession> doHandshake(
WebSocketHandler webSocketHandler, @Nullable WebSocketHttpHeaders headers, URI uri) {
return new org.springframework.util.concurrent.CompletableToListenableFutureAdapter<>(
execute(webSocketHandler, headers, uri));
}
/**
* Execute a handshake request to the given url and handle the resulting
* WebSocket session with the given handler.

View File

@@ -160,15 +160,6 @@ public class WebSocketMessageBrokerStats implements SmartInitializingSingleton {
}
/**
* Get stats about WebSocket sessions.
* @deprecated as of 6.2 in favor of {@link #getWebSocketSessionStats()}.
*/
@Deprecated(since = "6.2", forRemoval = true)
public String getWebSocketSessionStatsInfo() {
return (this.webSocketHandler != null ? this.webSocketHandler.getStatsInfo() : "null");
}
/**
* Get stats about WebSocket sessions.
* Can return {@code null} if no {@link #setSubProtocolWebSocketHandler(SubProtocolWebSocketHandler) WebSocket handler}
@@ -180,15 +171,6 @@ public class WebSocketMessageBrokerStats implements SmartInitializingSingleton {
return (this.webSocketHandler != null ? this.webSocketHandler.getStats() : null);
}
/**
* Get stats about STOMP-related WebSocket message processing.
* @deprecated as of 6.2 in favor of {@link #getStompSubProtocolStats()}.
*/
@Deprecated(since = "6.2", forRemoval = true)
public String getStompSubProtocolStatsInfo() {
return (this.stompSubProtocolHandler != null ? this.stompSubProtocolHandler.getStatsInfo() : "null");
}
/**
* Get stats about STOMP-related WebSocket message processing.
* Can return {@code null} if no {@link SubProtocolHandler} was found.
@@ -199,15 +181,6 @@ public class WebSocketMessageBrokerStats implements SmartInitializingSingleton {
return (this.stompSubProtocolHandler != null ? this.stompSubProtocolHandler.getStats() : null);
}
/**
* Get stats about STOMP broker relay (when using a full-featured STOMP broker).
* @deprecated as of 6.2 in favor of {@link #getStompBrokerRelayStats()}.
*/
@Deprecated(since = "6.2", forRemoval = true)
public String getStompBrokerRelayStatsInfo() {
return (this.stompBrokerRelay != null ? this.stompBrokerRelay.getStatsInfo() : "null");
}
/**
* Get stats about STOMP broker relay (when using a full-featured STOMP broker).
* Can return {@code null} if no {@link #setStompBrokerRelay(StompBrokerRelayMessageHandler) STOMP broker relay}
@@ -281,11 +254,10 @@ public class WebSocketMessageBrokerStats implements SmartInitializingSingleton {
}
@Override
@SuppressWarnings("removal")
public String toString() {
return "WebSocketSession[" + getWebSocketSessionStatsInfo() + "]" +
", stompSubProtocol[" + getStompSubProtocolStatsInfo() + "]" +
", stompBrokerRelay[" + getStompBrokerRelayStatsInfo() + "]" +
return "WebSocketSession[" + getWebSocketSessionStats() + "]" +
", stompSubProtocol[" + getStompSubProtocolStats() + "]" +
", stompBrokerRelay[" + getStompBrokerRelayStats() + "]" +
", inboundChannel[" + getClientInboundExecutorStatsInfo() + "]" +
", outboundChannel[" + getClientOutboundExecutorStatsInfo() + "]" +
", sockJsScheduler[" + getSockJsTaskSchedulerStatsInfo() + "]";

View File

@@ -227,25 +227,6 @@ public class WebSocketStompClient extends StompClientSupport implements SmartLif
}
/**
* Connect to the given WebSocket URL and notify the given
* {@link org.springframework.messaging.simp.stomp.StompSessionHandler}
* when connected on the STOMP level after the CONNECTED frame is received.
* @param url the url to connect to
* @param handler the session handler
* @param uriVars the URI variables to expand into the URL
* @return a {@code ListenableFuture} for access to the session when ready for use
* @deprecated as of 6.0, in favor of {@link #connectAsync(String, StompSessionHandler, Object...)}
*/
@Deprecated(since = "6.0", forRemoval = true)
@SuppressWarnings("removal")
public org.springframework.util.concurrent.ListenableFuture<StompSession> connect(
String url, StompSessionHandler handler, Object... uriVars) {
return new org.springframework.util.concurrent.CompletableToListenableFutureAdapter<>(
connectAsync(url, handler, uriVars));
}
/**
* Connect to the given WebSocket URL and notify the given
* {@link org.springframework.messaging.simp.stomp.StompSessionHandler}
@@ -262,28 +243,7 @@ public class WebSocketStompClient extends StompClientSupport implements SmartLif
/**
* An overloaded version of
* {@link #connect(String, StompSessionHandler, Object...)} that also
* accepts {@link WebSocketHttpHeaders} to use for the WebSocket handshake.
* @param url the url to connect to
* @param handshakeHeaders the headers for the WebSocket handshake
* @param handler the session handler
* @param uriVariables the URI variables to expand into the URL
* @return a {@code ListenableFuture} for access to the session when ready for use
* @deprecated as of 6.0, in favor of {@link #connectAsync(String, WebSocketHttpHeaders, StompSessionHandler, Object...)}
*/
@Deprecated(since = "6.0", forRemoval = true)
@SuppressWarnings("removal")
public org.springframework.util.concurrent.ListenableFuture<StompSession> connect(
String url, @Nullable WebSocketHttpHeaders handshakeHeaders,
StompSessionHandler handler, Object... uriVariables) {
return new org.springframework.util.concurrent.CompletableToListenableFutureAdapter<>(
connectAsync(url, handshakeHeaders, null, handler, uriVariables));
}
/**
* An overloaded version of
* {@link #connect(String, StompSessionHandler, Object...)} that also
* {@link #connectAsync(String, StompSessionHandler, Object...)} that also
* accepts {@link WebSocketHttpHeaders} to use for the WebSocket handshake.
* @param url the url to connect to
* @param handshakeHeaders the headers for the WebSocket handshake
@@ -300,30 +260,7 @@ public class WebSocketStompClient extends StompClientSupport implements SmartLif
/**
* An overloaded version of
* {@link #connect(String, StompSessionHandler, Object...)} that also accepts
* {@link WebSocketHttpHeaders} to use for the WebSocket handshake and
* {@link StompHeaders} for the STOMP CONNECT frame.
* @param url the url to connect to
* @param handshakeHeaders headers for the WebSocket handshake
* @param connectHeaders headers for the STOMP CONNECT frame
* @param handler the session handler
* @param uriVariables the URI variables to expand into the URL
* @return a {@code ListenableFuture} for access to the session when ready for use
* @deprecated as of 6.0, in favor of {@link #connectAsync(String, WebSocketHttpHeaders, StompHeaders, StompSessionHandler, Object...)}
*/
@Deprecated(since = "6.0", forRemoval = true)
@SuppressWarnings("removal")
public org.springframework.util.concurrent.ListenableFuture<StompSession> connect(
String url, @Nullable WebSocketHttpHeaders handshakeHeaders,
@Nullable StompHeaders connectHeaders, StompSessionHandler handler, Object... uriVariables) {
return new org.springframework.util.concurrent.CompletableToListenableFutureAdapter<>(
connectAsync(url, handshakeHeaders, connectHeaders, handler, uriVariables));
}
/**
* An overloaded version of
* {@link #connect(String, StompSessionHandler, Object...)} that also accepts
* {@link #connectAsync(String, StompSessionHandler, Object...)} that also accepts
* {@link WebSocketHttpHeaders} to use for the WebSocket handshake and
* {@link StompHeaders} for the STOMP CONNECT frame.
* @param url the url to connect to
@@ -344,28 +281,7 @@ public class WebSocketStompClient extends StompClientSupport implements SmartLif
/**
* An overloaded version of
* {@link #connect(String, WebSocketHttpHeaders, StompSessionHandler, Object...)}
* that accepts a fully prepared {@link java.net.URI}.
* @param url the url to connect to
* @param handshakeHeaders the headers for the WebSocket handshake
* @param connectHeaders headers for the STOMP CONNECT frame
* @param sessionHandler the STOMP session handler
* @return a {@code ListenableFuture} for access to the session when ready for use
* @deprecated as of 6.0, in favor of {@link #connectAsync(URI, WebSocketHttpHeaders, StompHeaders, StompSessionHandler)}
*/
@Deprecated(since = "6.0", forRemoval = true)
@SuppressWarnings("removal")
public org.springframework.util.concurrent.ListenableFuture<StompSession> connect(
URI url, @Nullable WebSocketHttpHeaders handshakeHeaders,
@Nullable StompHeaders connectHeaders, StompSessionHandler sessionHandler) {
return new org.springframework.util.concurrent.CompletableToListenableFutureAdapter<>(
connectAsync(url, handshakeHeaders, connectHeaders, sessionHandler));
}
/**
* An overloaded version of
* {@link #connect(String, WebSocketHttpHeaders, StompSessionHandler, Object...)}
* {@link #connectAsync(String, WebSocketHttpHeaders, StompSessionHandler, Object...)}
* that accepts a fully prepared {@link java.net.URI}.
* @param url the url to connect to
* @param handshakeHeaders the headers for the WebSocket handshake

View File

@@ -68,17 +68,6 @@ public abstract class AbstractClientSockJsSession implements WebSocketSession {
private volatile CloseStatus closeStatus;
/**
* Create a new {@code AbstractClientSockJsSession}.
* @deprecated as of 6.0, in favor of {@link #AbstractClientSockJsSession(TransportRequest, WebSocketHandler, CompletableFuture)}
*/
@Deprecated(since = "6.0", forRemoval = true)
@SuppressWarnings("removal")
protected AbstractClientSockJsSession(TransportRequest request, WebSocketHandler handler,
org.springframework.util.concurrent.SettableListenableFuture<WebSocketSession> connectFuture) {
this(request, handler, connectFuture.completable());
}
protected AbstractClientSockJsSession(TransportRequest request, WebSocketHandler handler,
CompletableFuture<WebSocketSession> connectFuture) {

View File

@@ -108,15 +108,6 @@ public abstract class AbstractXhrTransport implements XhrTransport {
return connectFuture;
}
@Deprecated(since = "6.0", forRemoval = true)
@SuppressWarnings("removal")
protected void connectInternal(TransportRequest request, WebSocketHandler handler,
URI receiveUrl, HttpHeaders handshakeHeaders, XhrClientSockJsSession session,
org.springframework.util.concurrent.SettableListenableFuture<WebSocketSession> connectFuture) {
throw new UnsupportedOperationException("connectInternal has been deprecated in favor of connectInternal");
}
protected abstract void connectInternal(TransportRequest request, WebSocketHandler handler,
URI receiveUrl, HttpHeaders handshakeHeaders, XhrClientSockJsSession session,
CompletableFuture<WebSocketSession> connectFuture);

View File

@@ -146,19 +146,6 @@ class DefaultTransportRequest implements TransportRequest {
}
@Deprecated(since = "6.0", forRemoval = true)
@SuppressWarnings({"deprecation", "removal"})
public void connect(WebSocketHandler handler,
org.springframework.util.concurrent.SettableListenableFuture<WebSocketSession> future) {
if (logger.isTraceEnabled()) {
logger.trace("Starting " + this);
}
ListenableConnectCallback connectCallback = new ListenableConnectCallback(handler, future);
scheduleConnectTimeoutTask(connectCallback);
this.transport.connect(this, handler).addCallback(connectCallback);
}
public void connect(WebSocketHandler handler, CompletableFuture<WebSocketSession> future) {
if (logger.isTraceEnabled()) {
logger.trace("Starting " + this);
@@ -169,19 +156,6 @@ class DefaultTransportRequest implements TransportRequest {
}
private void scheduleConnectTimeoutTask(ListenableConnectCallback connectHandler) {
if (this.timeoutScheduler != null) {
if (logger.isTraceEnabled()) {
logger.trace("Scheduling connect to time out after " + this.timeoutValue + " ms.");
}
Instant timeoutDate = Instant.now().plus(this.timeoutValue, ChronoUnit.MILLIS);
this.timeoutScheduler.schedule(connectHandler, timeoutDate);
}
else if (logger.isTraceEnabled()) {
logger.trace("Connect timeout task not scheduled (no TaskScheduler configured).");
}
}
private void scheduleConnectTimeoutTask(CompletableConnectCallback connectHandler) {
if (this.timeoutScheduler != null) {
if (logger.isTraceEnabled()) {
@@ -202,83 +176,6 @@ class DefaultTransportRequest implements TransportRequest {
}
/**
* Updates the given (global) future based success or failure to connect for
* the entire SockJS request regardless of which transport actually managed
* to connect. Also implements {@code Runnable} to handle a scheduled timeout
* callback.
*/
@SuppressWarnings({"deprecation", "removal"})
private class ListenableConnectCallback implements
org.springframework.util.concurrent.ListenableFutureCallback<WebSocketSession>, Runnable {
private final WebSocketHandler handler;
private final org.springframework.util.concurrent.SettableListenableFuture<WebSocketSession> future;
private final AtomicBoolean handled = new AtomicBoolean();
public ListenableConnectCallback(WebSocketHandler handler,
org.springframework.util.concurrent.SettableListenableFuture<WebSocketSession> future) {
this.handler = handler;
this.future = future;
}
@Override
public void onSuccess(@Nullable WebSocketSession session) {
if (this.handled.compareAndSet(false, true)) {
this.future.set(session);
}
else if (logger.isErrorEnabled()) {
logger.error("Connect success/failure already handled for " + DefaultTransportRequest.this);
}
}
@Override
public void onFailure(Throwable ex) {
handleFailure(ex, false);
}
@Override
public void run() {
handleFailure(null, true);
}
private void handleFailure(@Nullable Throwable ex, boolean isTimeoutFailure) {
if (this.handled.compareAndSet(false, true)) {
if (isTimeoutFailure) {
String message = "Connect timed out for " + DefaultTransportRequest.this;
logger.error(message);
ex = new SockJsTransportFailureException(message, getSockJsUrlInfo().getSessionId(), ex);
}
if (fallbackRequest != null) {
logger.error(DefaultTransportRequest.this + " failed. Falling back on next transport.", ex);
fallbackRequest.connect(this.handler, this.future);
}
else {
logger.error("No more fallback transports after " + DefaultTransportRequest.this, ex);
if (ex != null) {
this.future.setException(ex);
}
}
if (isTimeoutFailure) {
try {
for (Runnable runnable : timeoutTasks) {
runnable.run();
}
}
catch (Throwable ex2) {
logger.error("Transport failed to run timeout tasks for " + DefaultTransportRequest.this, ex2);
}
}
}
else {
logger.error("Connect success/failure events already took place for " +
DefaultTransportRequest.this + ". Ignoring this additional failure event.", ex);
}
}
}
/**
* Updates the given (global) future based success or failure to connect for
* the entire SockJS request regardless of which transport actually managed

View File

@@ -38,22 +38,6 @@ public interface Transport {
*/
List<TransportType> getTransportTypes();
/**
* Connect the transport.
* @param request the transport request
* @param webSocketHandler the application handler to delegate lifecycle events to
* @return a future to indicate success or failure to connect
* @deprecated as of 6.0, in favor of {@link #connectAsync(TransportRequest, WebSocketHandler)}
*/
@Deprecated(since = "6.0", forRemoval = true)
@SuppressWarnings("removal")
default org.springframework.util.concurrent.ListenableFuture<WebSocketSession> connect(
TransportRequest request, WebSocketHandler webSocketHandler) {
return new org.springframework.util.concurrent.CompletableToListenableFutureAdapter<>(
connectAsync(request, webSocketHandler));
}
/**
* Connect the transport.
* @param request the transport request

View File

@@ -43,18 +43,6 @@ public class WebSocketClientSockJsSession extends AbstractClientSockJsSession im
private WebSocketSession webSocketSession;
/**
* Create a new {@code WebSocketClientSockJsSession}.
* @deprecated as of 6.0, in favor of {@link #WebSocketClientSockJsSession(TransportRequest, WebSocketHandler, CompletableFuture)}
*/
@Deprecated(since = "6.0", forRemoval = true)
@SuppressWarnings("removal")
public WebSocketClientSockJsSession(TransportRequest request, WebSocketHandler handler,
org.springframework.util.concurrent.SettableListenableFuture<WebSocketSession> connectFuture) {
super(request, handler, connectFuture);
}
public WebSocketClientSockJsSession(TransportRequest request, WebSocketHandler handler,
CompletableFuture<WebSocketSession> connectFuture) {

View File

@@ -55,27 +55,6 @@ public class XhrClientSockJsSession extends AbstractClientSockJsSession {
private int binaryMessageSizeLimit = -1;
/**
* Create a new {@code XhrClientSockJsSession}.
* @deprecated as of 6.0, in favor of
* {@link #XhrClientSockJsSession(TransportRequest, WebSocketHandler, XhrTransport, CompletableFuture)}
*/
@Deprecated(since = "6.0", forRemoval = true)
@SuppressWarnings("removal")
public XhrClientSockJsSession(
TransportRequest request, WebSocketHandler handler, XhrTransport transport,
org.springframework.util.concurrent.SettableListenableFuture<WebSocketSession> connectFuture) {
super(request, handler, connectFuture);
Assert.notNull(transport, "XhrTransport is required");
this.transport = transport;
this.headers = request.getHttpRequestHeaders();
this.sendHeaders = new HttpHeaders();
this.sendHeaders.putAll(this.headers);
this.sendHeaders.setContentType(MediaType.APPLICATION_JSON);
this.sendUrl = request.getSockJsUrlInfo().getTransportUrl(TransportType.XHR_SEND);
}
/**
* Create a new {@code XhrClientSockJsSession}.
* @since 6.0

View File

@@ -84,7 +84,6 @@ class XhrTransportTests {
}
@Test
@SuppressWarnings({"deprecation", "removal"})
void connect() {
HttpHeaders handshakeHeaders = new HttpHeaders();
handshakeHeaders.setOrigin("foo");
@@ -96,7 +95,7 @@ class XhrTransportTests {
TestXhrTransport transport = new TestXhrTransport();
WebSocketHandler handler = mock();
transport.connect(request, handler);
transport.connectAsync(request, handler);
ArgumentCaptor<Runnable> captor = ArgumentCaptor.forClass(Runnable.class);
verify(request).getSockJsUrlInfo();
@@ -127,7 +126,6 @@ class XhrTransportTests {
private XhrClientSockJsSession actualSession;
@Override
protected ResponseEntity<String> executeInfoRequestInternal(URI infoUrl, HttpHeaders headers) {
return this.infoResponseToReturn;