Use new Java features (switch expressions, text blocks, new JDK methods)
Closes gh-29747
This commit is contained in:
committed by
Sam Brannen
parent
48abd493fe
commit
afb8a0d1b1
@@ -427,7 +427,7 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void handleMessageToClient(WebSocketSession session, Message<?> message) {
|
||||
if (!(message.getPayload() instanceof byte[])) {
|
||||
if (!(message.getPayload() instanceof byte[] payload)) {
|
||||
if (logger.isErrorEnabled()) {
|
||||
logger.error("Expected byte[] payload. Ignoring " + message + ".");
|
||||
}
|
||||
@@ -464,7 +464,6 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
|
||||
}
|
||||
}
|
||||
|
||||
byte[] payload = (byte[]) message.getPayload();
|
||||
if (StompCommand.ERROR.equals(command) && getErrorHandler() != null) {
|
||||
Message<byte[]> errorMessage = getErrorHandler().handleErrorMessageToClient((Message<byte[]>) message);
|
||||
if (errorMessage != null) {
|
||||
|
||||
@@ -229,19 +229,14 @@ public abstract class AbstractClientSockJsSession implements WebSocketSession {
|
||||
public void handleFrame(String payload) {
|
||||
SockJsFrame frame = new SockJsFrame(payload);
|
||||
switch (frame.getType()) {
|
||||
case OPEN:
|
||||
handleOpenFrame();
|
||||
break;
|
||||
case HEARTBEAT:
|
||||
case OPEN -> handleOpenFrame();
|
||||
case HEARTBEAT -> {
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Received heartbeat in " + this);
|
||||
}
|
||||
break;
|
||||
case MESSAGE:
|
||||
handleMessageFrame(frame);
|
||||
break;
|
||||
case CLOSE:
|
||||
handleCloseFrame(frame);
|
||||
}
|
||||
case MESSAGE -> handleMessageFrame(frame);
|
||||
case CLOSE -> handleCloseFrame(frame);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -276,12 +276,11 @@ public class TransportHandlingSockJsService extends AbstractSockJsService implem
|
||||
SockJsSession session = this.sessions.get(sessionId);
|
||||
boolean isNewSession = false;
|
||||
if (session == null) {
|
||||
if (transportHandler instanceof SockJsSessionFactory) {
|
||||
if (transportHandler instanceof SockJsSessionFactory sessionFactory) {
|
||||
Map<String, Object> attributes = new HashMap<>();
|
||||
if (!chain.applyBeforeHandshake(request, response, attributes)) {
|
||||
return;
|
||||
}
|
||||
SockJsSessionFactory sessionFactory = (SockJsSessionFactory) transportHandler;
|
||||
session = createSockJsSession(sessionId, sessionFactory, handler, attributes);
|
||||
isNewSession = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user