11/*
2- * Copyright 2002-2015 the original author or authors.
2+ * Copyright 2002-2016 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
2828import org .springframework .messaging .simp .SimpMessageHeaderAccessor ;
2929import org .springframework .messaging .simp .SimpMessageType ;
3030import org .springframework .messaging .support .MessageHeaderAccessor ;
31- import org .springframework .util .Assert ;
31+ import org .springframework .util .ClassUtils ;
3232import org .springframework .util .MimeType ;
3333import org .springframework .util .MimeTypeUtils ;
3434import org .springframework .util .StringUtils ;
@@ -185,7 +185,9 @@ Map<String, List<String>> getNativeHeaders() {
185185 }
186186
187187 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+ }
189191 if (getCommand () == null ) {
190192 setHeader (COMMAND_HEADER , StompCommand .SEND );
191193 }
@@ -196,7 +198,9 @@ else if (!getCommand().equals(StompCommand.SEND)) {
196198 }
197199
198200 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+ }
200204 StompCommand command = getCommand ();
201205 if ((command == null ) || StompCommand .SEND .equals (command )) {
202206 setHeader (COMMAND_HEADER , StompCommand .MESSAGE );
@@ -434,7 +438,10 @@ private String appendSession() {
434438 }
435439
436440 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+ }
438445 byte [] bytes = (byte []) payload ;
439446 String contentType = (getContentType () != null ? " " + getContentType ().toString () : "" );
440447 if (bytes .length == 0 || getContentType () == null || !isReadableContentType ()) {
0 commit comments