1
1
/*
2
- * Copyright 2002-2015 the original author or authors.
2
+ * Copyright 2002-2016 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
28
28
import org .springframework .messaging .simp .SimpMessageHeaderAccessor ;
29
29
import org .springframework .messaging .simp .SimpMessageType ;
30
30
import org .springframework .messaging .support .MessageHeaderAccessor ;
31
- import org .springframework .util .Assert ;
31
+ import org .springframework .util .ClassUtils ;
32
32
import org .springframework .util .MimeType ;
33
33
import org .springframework .util .MimeTypeUtils ;
34
34
import org .springframework .util .StringUtils ;
@@ -185,7 +185,9 @@ Map<String, List<String>> getNativeHeaders() {
185
185
}
186
186
187
187
public StompCommand updateStompCommandAsClientMessage () {
188
- Assert .state (SimpMessageType .MESSAGE .equals (getMessageType ()), "Unexpected message type " + getMessage ());
188
+ if (getMessageType () != SimpMessageType .MESSAGE ) {
189
+ throw new IllegalStateException ("Unexpected message type " + getMessageType ());
190
+ }
189
191
if (getCommand () == null ) {
190
192
setHeader (COMMAND_HEADER , StompCommand .SEND );
191
193
}
@@ -196,7 +198,9 @@ else if (!getCommand().equals(StompCommand.SEND)) {
196
198
}
197
199
198
200
public void updateStompCommandAsServerMessage () {
199
- Assert .state (SimpMessageType .MESSAGE .equals (getMessageType ()), "Unexpected message type " + getMessage ());
201
+ if (getMessageType () != SimpMessageType .MESSAGE ) {
202
+ throw new IllegalStateException ("Unexpected message type " + getMessageType ());
203
+ }
200
204
StompCommand command = getCommand ();
201
205
if ((command == null ) || StompCommand .SEND .equals (command )) {
202
206
setHeader (COMMAND_HEADER , StompCommand .MESSAGE );
@@ -434,7 +438,10 @@ private String appendSession() {
434
438
}
435
439
436
440
private String appendPayload (Object payload ) {
437
- Assert .isInstanceOf (byte [].class , payload );
441
+ if (payload .getClass () != byte [].class ) {
442
+ throw new IllegalStateException (
443
+ "Expected byte array payload but got: " + ClassUtils .getQualifiedName (payload .getClass ()));
444
+ }
438
445
byte [] bytes = (byte []) payload ;
439
446
String contentType = (getContentType () != null ? " " + getContentType ().toString () : "" );
440
447
if (bytes .length == 0 || getContentType () == null || !isReadableContentType ()) {
0 commit comments