33 *
44 * All rights reserved. This program and the accompanying materials
55 * are made available under the terms of the Eclipse Public License v1.0
6- * and Eclipse Distribution License v1.0 which accompany this distribution.
6+ * and Eclipse Distribution License v1.0 which accompany this distribution.
77 *
8- * The Eclipse Public License is available at
8+ * The Eclipse Public License is available at
99 * http://www.eclipse.org/legal/epl-v10.html
10- * and the Eclipse Distribution License is available at
10+ * and the Eclipse Distribution License is available at
1111 * http://www.eclipse.org/org/documents/edl-v10.php.
1212 *
1313 * Contributors:
@@ -44,15 +44,15 @@ public class CommsReceiver implements Runnable {
4444 private CommsTokenStore tokenStore = null ;
4545 private Thread recThread = null ;
4646 private volatile boolean receiving ;
47-
47+
4848 public CommsReceiver (ClientComms clientComms , ClientState clientState ,CommsTokenStore tokenStore , InputStream in ) {
4949 this .in = new MqttInputStream (clientState , in );
5050 this .clientComms = clientComms ;
5151 this .clientState = clientState ;
5252 this .tokenStore = tokenStore ;
5353 log .setResourceName (clientComms .getClient ().getClientId ());
5454 }
55-
55+
5656 /**
5757 * Starts up the Receiver's thread.
5858 * @param threadName The name of the thread
@@ -100,29 +100,29 @@ public void stop() {
100100 //@TRACE 851=stopped
101101 log .fine (CLASS_NAME ,methodName ,"851" );
102102 }
103-
103+
104104 /**
105105 * Run loop to receive messages from the server.
106106 */
107107 public void run () {
108108 final String methodName = "run" ;
109109 MqttToken token = null ;
110-
110+
111111 while (running && (in != null )) {
112112 try {
113113 //@TRACE 852=network read message
114114 log .fine (CLASS_NAME ,methodName ,"852" );
115115 receiving = in .available () > 0 ;
116116 MqttWireMessage message = in .readMqttWireMessage ();
117117 receiving = false ;
118-
118+
119119 // instanceof checks if message is null
120120 if (message instanceof MqttAck ) {
121121 token = tokenStore .getToken (message );
122122 if (token !=null ) {
123123 synchronized (token ) {
124124 // Ensure the notify processing is done under a lock on the token
125- // This ensures that the send processing can complete before the
125+ // This ensures that the send processing can complete before the
126126 // receive processing starts! ( request and ack and ack processing
127127 // can occur before request processing is complete if not!
128128 clientState .notifyReceivedAck ((MqttAck )message );
@@ -133,7 +133,6 @@ public void run() {
133133 //because of timeouts, crashes, disconnects, restarts etc.
134134 //It should be safe to ignore these unexpected messages.
135135 log .fine (CLASS_NAME , methodName , "857" );
136-
137136 } else {
138137 // It its an ack and there is no token then something is not right.
139138 // An ack should always have a token assoicated with it.
@@ -152,13 +151,13 @@ public void run() {
152151 running = false ;
153152 // Token maybe null but that is handled in shutdown
154153 clientComms .shutdownConnection (token , ex );
155- }
154+ }
156155 catch (IOException ioe ) {
157156 //@TRACE 853=Stopping due to IOException
158157 log .fine (CLASS_NAME ,methodName ,"853" );
159158
160159 running = false ;
161- // An EOFException could be raised if the broker processes the
160+ // An EOFException could be raised if the broker processes the
162161 // DISCONNECT and ends the socket before we complete. As such,
163162 // only shutdown the connection if we're not already shutting down.
164163 if (!clientComms .isDisconnecting ()) {
@@ -169,18 +168,18 @@ public void run() {
169168 receiving = false ;
170169 }
171170 }
172-
171+
173172 //@TRACE 854=<
174173 log .fine (CLASS_NAME ,methodName ,"854" );
175174 }
176-
175+
177176 public boolean isRunning () {
178177 return running ;
179178 }
180-
179+
181180 /**
182181 * Returns the receiving state.
183- *
182+ *
184183 * @return true if the receiver is receiving data, false otherwise.
185184 */
186185 public boolean isReceiving () {
0 commit comments