1818
1919import java .lang .reflect .Type ;
2020import java .util .ArrayList ;
21- import java .util .Arrays ;
21+ import java .util .Collections ;
2222import java .util .Date ;
2323import java .util .List ;
2424import java .util .Map ;
@@ -79,7 +79,8 @@ public class DefaultStompSession implements ConnectionHandlingStompSession {
7979
8080 private final StompHeaders connectHeaders ;
8181
82- private final SettableListenableFuture <StompSession > sessionFuture = new SettableListenableFuture <StompSession >();
82+ private final SettableListenableFuture <StompSession > sessionFuture =
83+ new SettableListenableFuture <StompSession >();
8384
8485 private MessageConverter converter = new SimpleMessageConverter ();
8586
@@ -96,11 +97,13 @@ public class DefaultStompSession implements ConnectionHandlingStompSession {
9697
9798 private final AtomicInteger subscriptionIndex = new AtomicInteger ();
9899
99- private final Map <String , DefaultSubscription > subscriptions = new ConcurrentHashMap <String , DefaultSubscription >(4 );
100+ private final Map <String , DefaultSubscription > subscriptions =
101+ new ConcurrentHashMap <String , DefaultSubscription >(4 );
100102
101103 private final AtomicInteger receiptIndex = new AtomicInteger ();
102104
103- private final Map <String , ReceiptHandler > receiptHandlers = new ConcurrentHashMap <String , ReceiptHandler >(4 );
105+ private final Map <String , ReceiptHandler > receiptHandlers =
106+ new ConcurrentHashMap <String , ReceiptHandler >(4 );
104107
105108 /* Whether the client is willfully closing the connection */
106109 private volatile boolean closing = false ;
@@ -112,8 +115,8 @@ public class DefaultStompSession implements ConnectionHandlingStompSession {
112115 * @param connectHeaders headers for the STOMP CONNECT frame
113116 */
114117 public DefaultStompSession (StompSessionHandler sessionHandler , StompHeaders connectHeaders ) {
115- Assert .notNull (sessionHandler , "'sessionHandler' is required. " );
116- Assert .notNull (connectHeaders , "'connectHeaders' is required. " );
118+ Assert .notNull (sessionHandler , "StompSessionHandler must not be null " );
119+ Assert .notNull (connectHeaders , "StompHeaders must not be null " );
117120 this .sessionId = idGenerator .generateId ().toString ();
118121 this .sessionHandler = sessionHandler ;
119122 this .connectHeaders = connectHeaders ;
@@ -145,7 +148,7 @@ public ListenableFuture<StompSession> getSessionFuture() {
145148 * @param messageConverter the message converter to use
146149 */
147150 public void setMessageConverter (MessageConverter messageConverter ) {
148- Assert .notNull (messageConverter , "'messageConverter' must not be null" );
151+ Assert .notNull (messageConverter , "MessageConverter must not be null" );
149152 this .converter = messageConverter ;
150153 }
151154
@@ -213,7 +216,7 @@ public Receiptable send(String destination, Object payload) {
213216
214217 @ Override
215218 public Receiptable send (StompHeaders stompHeaders , Object payload ) {
216- Assert .hasText (stompHeaders .getDestination (), "'destination' header is required" );
219+ Assert .hasText (stompHeaders .getDestination (), "Destination header is required" );
217220
218221 String receiptId = checkOrAddReceipt (stompHeaders );
219222 Receiptable receiptable = new ReceiptHandler (receiptId );
@@ -292,8 +295,8 @@ public Subscription subscribe(String destination, StompFrameHandler handler) {
292295 @ Override
293296 public Subscription subscribe (StompHeaders stompHeaders , StompFrameHandler handler ) {
294297 String destination = stompHeaders .getDestination ();
295- Assert .hasText (destination , "'destination' is required" );
296- Assert .notNull (handler , "'handler' is required " );
298+ Assert .hasText (destination , "Destination header is required" );
299+ Assert .notNull (handler , "StompFrameHandler must not be null " );
297300
298301 String subscriptionId = stompHeaders .getId ();
299302 if (!StringUtils .hasText (subscriptionId )) {
@@ -397,7 +400,7 @@ public void handleMessage(Message<byte[]> message) {
397400 }
398401 else if (logger .isDebugEnabled ()) {
399402 logger .debug ("No handler for: " + accessor .getDetailedLogMessage (message .getPayload ()) +
400- ". Perhaps just unscubscribed ?" );
403+ ". Perhaps just unsubscribed ?" );
401404 }
402405 }
403406 else {
@@ -464,7 +467,7 @@ private void initHeartbeatTasks(StompHeaders connectedHeaders) {
464467 @ Override
465468 public void handleFailure (Throwable ex ) {
466469 try {
467- this .sessionFuture .setException (ex ); // no-op if already set
470+ this .sessionFuture .setException (ex ); // no-op if already set
468471 this .sessionHandler .handleTransportError (this , ex );
469472 }
470473 catch (Throwable ex2 ) {
@@ -477,7 +480,7 @@ public void handleFailure(Throwable ex) {
477480 @ Override
478481 public void afterConnectionClosed () {
479482 if (logger .isDebugEnabled ()) {
480- logger .debug ("Connection closed session id=" + this .sessionId );
483+ logger .debug ("Connection closed in session id=" + this .sessionId );
481484 }
482485 if (!this .closing ) {
483486 resetConnection ();
@@ -493,7 +496,7 @@ private void resetConnection() {
493496 conn .close ();
494497 }
495498 catch (Throwable ex ) {
496- // Ignore
499+ // ignore
497500 }
498501 }
499502 }
@@ -519,7 +522,7 @@ public ReceiptHandler(String receiptId) {
519522 }
520523
521524 private void initReceiptHandling () {
522- Assert .notNull (getTaskScheduler (), "To track receipts a TaskScheduler must be configured" );
525+ Assert .notNull (getTaskScheduler (), "To track receipts, a TaskScheduler must be configured" );
523526 DefaultStompSession .this .receiptHandlers .put (this .receiptId , this );
524527 Date startTime = new Date (System .currentTimeMillis () + getReceiptTimeLimit ());
525528 this .future = getTaskScheduler ().schedule (new Runnable () {
@@ -546,10 +549,11 @@ public void addReceiptLostTask(Runnable task) {
546549 }
547550
548551 private void addTask (Runnable task , boolean successTask ) {
549- Assert .notNull (this .receiptId , "To track receipts, set autoReceiptEnabled=true or add 'receiptId' header" );
552+ Assert .notNull (this .receiptId ,
553+ "To track receipts, set autoReceiptEnabled=true or add 'receiptId' header" );
550554 synchronized (this ) {
551555 if (this .result != null && this .result == successTask ) {
552- invoke (Arrays . asList (task ));
556+ invoke (Collections . singletonList (task ));
553557 }
554558 else {
555559 if (successTask ) {
@@ -568,7 +572,7 @@ private void invoke(List<Runnable> callbacks) {
568572 runnable .run ();
569573 }
570574 catch (Throwable ex ) {
571- // Ignore
575+ // ignore
572576 }
573577 }
574578 }
@@ -607,12 +611,11 @@ private class DefaultSubscription extends ReceiptHandler implements Subscription
607611
608612 public DefaultSubscription (String id , String destination , String receiptId , StompFrameHandler handler ) {
609613 super (receiptId );
610- Assert .notNull (destination , "'destination' is required " );
611- Assert .notNull (handler , "'handler' handler is required " );
614+ Assert .notNull (destination , "Destination must not be null " );
615+ Assert .notNull (handler , "StompFrameHandler must not be null " );
612616 this .id = id ;
613617 this .destination = destination ;
614618 this .handler = handler ;
615-
616619 DefaultStompSession .this .subscriptions .put (id , this );
617620 }
618621
0 commit comments