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.
29
29
import org .springframework .messaging .simp .SimpMessageHeaderAccessor ;
30
30
import org .springframework .messaging .simp .SimpMessageType ;
31
31
import org .springframework .messaging .support .MessageHeaderAccessor ;
32
- import org .springframework .util .Assert ;
32
+ import org .springframework .util .ClassUtils ;
33
33
import org .springframework .util .MimeType ;
34
34
import org .springframework .util .MimeTypeUtils ;
35
35
import org .springframework .util .StringUtils ;
@@ -186,7 +186,9 @@ Map<String, List<String>> getNativeHeaders() {
186
186
}
187
187
188
188
public StompCommand updateStompCommandAsClientMessage () {
189
- Assert .state (SimpMessageType .MESSAGE .equals (getMessageType ()), "Unexpected message type " + getMessage ());
189
+ if (getMessageType () != SimpMessageType .MESSAGE ) {
190
+ throw new IllegalStateException ("Unexpected message type " + getMessageType ());
191
+ }
190
192
if (getCommand () == null ) {
191
193
setHeader (COMMAND_HEADER , StompCommand .SEND );
192
194
}
@@ -197,7 +199,9 @@ else if (!getCommand().equals(StompCommand.SEND)) {
197
199
}
198
200
199
201
public void updateStompCommandAsServerMessage () {
200
- Assert .state (SimpMessageType .MESSAGE .equals (getMessageType ()), "Unexpected message type " + getMessage ());
202
+ if (getMessageType () != SimpMessageType .MESSAGE ) {
203
+ throw new IllegalStateException ("Unexpected message type " + getMessageType ());
204
+ }
201
205
StompCommand command = getCommand ();
202
206
if ((command == null ) || StompCommand .SEND .equals (command )) {
203
207
setHeader (COMMAND_HEADER , StompCommand .MESSAGE );
@@ -435,7 +439,10 @@ private String appendSession() {
435
439
}
436
440
437
441
private String appendPayload (Object payload ) {
438
- Assert .isInstanceOf (byte [].class , payload );
442
+ if (payload .getClass () != byte [].class ) {
443
+ throw new IllegalStateException (
444
+ "Expected byte array payload but got: " + ClassUtils .getQualifiedName (payload .getClass ()));
445
+ }
439
446
byte [] bytes = (byte []) payload ;
440
447
String contentType = (getContentType () != null ? " " + getContentType ().toString () : "" );
441
448
if (bytes .length == 0 || getContentType () == null || !isReadableContentType ()) {
0 commit comments