@@ -32,27 +32,27 @@ public abstract class WebSocketClient implements Runnable, WebSocketListener {
32
32
/**
33
33
* The URI this client is supposed to connect to.
34
34
*/
35
- private URI uri ;
35
+ private URI uri = null ;
36
36
/**
37
37
* The WebSocket instance this client object wraps.
38
38
*/
39
- private WebSocket conn ;
39
+ private WebSocket conn = null ;
40
40
/**
41
41
* The SocketChannel instance this client uses.
42
42
*/
43
- private SocketChannel client ;
43
+ private SocketChannel client = null ;
44
44
/**
45
45
* The 'Selector' used to get event keys from the underlying socket.
46
46
*/
47
- private Selector selector ;
47
+ private Selector selector = null ;
48
48
/**
49
49
* Keeps track of whether or not the client thread should continue running.
50
50
*/
51
- private boolean running ;
51
+ private boolean running = false ;
52
52
/**
53
53
* The Draft of the WebSocket protocol the Client is adhering to.
54
54
*/
55
- private WebSocketDraft draft ;
55
+ private WebSocketDraft draft = null ;
56
56
/**
57
57
* Number 1 used in handshake
58
58
*/
@@ -120,10 +120,7 @@ public void connect() {
120
120
*/
121
121
public void close () throws IOException
122
122
{
123
- Boolean active = running ;
124
- this .running = false ;
125
-
126
- if (active )
123
+ if (running )
127
124
{
128
125
selector .wakeup ();
129
126
conn .close ();
@@ -352,15 +349,19 @@ public void onOpen(WebSocket conn) {
352
349
*/
353
350
public void onClose (WebSocket conn )
354
351
{
355
- try
352
+ if ( running )
356
353
{
357
- close ();
358
- }
359
- catch (IOException ex )
360
- {
361
- onIOError (ex );
354
+ onClose ();
362
355
}
363
- onClose ();
356
+
357
+ conn = null ;
358
+ client = null ;
359
+ selector = null ;
360
+ running = false ;
361
+ draft = null ;
362
+ number1 = 0 ;
363
+ number2 = 0 ;
364
+ key3 = null ;
364
365
}
365
366
366
367
/**
0 commit comments