Browse Source

StompSubProtocolHandler does not insist on SimpMessageHeaderAccessor

Issue: SPR-14791
pull/1203/head
Juergen Hoeller 8 years ago
parent
commit
66722afda0
  1. 21
      spring-websocket/src/main/java/org/springframework/web/socket/messaging/StompSubProtocolHandler.java

21
spring-websocket/src/main/java/org/springframework/web/socket/messaging/StompSubProtocolHandler.java

@ -34,7 +34,6 @@ import org.springframework.context.ApplicationEventPublisher; @@ -34,7 +34,6 @@ import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageHeaders;
import org.springframework.messaging.simp.SimpAttributes;
import org.springframework.messaging.simp.SimpAttributesContextHolder;
import org.springframework.messaging.simp.SimpMessageHeaderAccessor;
@ -433,18 +432,13 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE @@ -433,18 +432,13 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
}
}
private StompHeaderAccessor getStompHeaderAccessor(Message<?> message) {
private StompHeaderAccessor getStompHeaderAccessor(Message<?> message) {
MessageHeaderAccessor accessor = MessageHeaderAccessor.getAccessor(message, MessageHeaderAccessor.class);
if (accessor == null) {
// Shouldn't happen (only broker broadcasts directly to clients)
throw new IllegalStateException("No header accessor in " + message);
}
StompHeaderAccessor stompAccessor;
if (accessor instanceof StompHeaderAccessor) {
stompAccessor = (StompHeaderAccessor) accessor;
return (StompHeaderAccessor) accessor;
}
else if (accessor instanceof SimpMessageHeaderAccessor) {
stompAccessor = StompHeaderAccessor.wrap(message);
else {
StompHeaderAccessor stompAccessor = StompHeaderAccessor.wrap(message);
SimpMessageType messageType = SimpMessageHeaderAccessor.getMessageType(message.getHeaders());
if (SimpMessageType.CONNECT_ACK.equals(messageType)) {
stompAccessor = convertConnectAcktoStompConnected(stompAccessor);
@ -466,13 +460,8 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE @@ -466,13 +460,8 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
else if (stompAccessor.getCommand() == null || StompCommand.SEND.equals(stompAccessor.getCommand())) {
stompAccessor.updateStompCommandAsServerMessage();
}
return stompAccessor;
}
else {
// Shouldn't happen (only broker broadcasts directly to clients)
throw new IllegalStateException(
"Unexpected header accessor type: " + accessor.getClass() + " in " + message);
}
return stompAccessor;
}
/**

Loading…
Cancel
Save