@@ -43,12 +43,11 @@ public BufferedNioConnection(final String host, final int port, final IConnectiv
4343 super (host , port , logger );
4444 }
4545
46- @ SuppressWarnings ("resource" )
4746 @ Override
4847 public void connect () throws IOException {
4948 if (isConnected ())
5049 return ;
51- InetSocketAddress address = new InetSocketAddress (host , port );
50+ final InetSocketAddress address = new InetSocketAddress (host , port );
5251 if (connectionEnabler != null )
5352 connectionEnabler .prepareConnection (host + ":" + port );
5453 channel = SocketChannel .open (address );
@@ -58,30 +57,30 @@ public void connect() throws IOException {
5857 @ Override
5958 public void run () {
6059 logInfo ("Reading thread start." );
61- ByteBuffer buffer = ByteBuffer .allocate (100000 );
60+ final ByteBuffer buffer = ByteBuffer .allocate (100000 );
6261 readLoop : while (true ) {
6362 try {
64- int ret = selector .select ();
63+ final int ret = selector .select ();
6564 if (ret > 0 ) {
6665 if (selector .selectedKeys ().contains (readKey )) {
6766 // We can read:
6867 buffer .rewind ();
69- int readCount = channel .read (buffer );
70- long readTime = System .currentTimeMillis ();
68+ final int readCount = channel .read (buffer );
69+ final long readTime = System .currentTimeMillis ();
7170 if (readCount == -1 ) {
7271 // End of stream
7372 break readLoop ;
7473 } else if (readCount > 0 ) {
75- byte [] data = new byte [readCount ];
74+ final byte [] data = new byte [readCount ];
7675 buffer .rewind ();
7776 buffer .get (data );
7877 processIncomingData (readTime , readCount , data );
7978 }
8079 }
8180 }
82- } catch (ClosedSelectorException cse ) {
81+ } catch (final ClosedSelectorException cse ) {
8382 break readLoop ;
84- } catch (IOException ioe ) {
83+ } catch (final IOException ioe ) {
8584 reportProblem ("Error reading data" , ioe );
8685 logError ("Reading thread error." , ioe );
8786 }
@@ -103,7 +102,7 @@ public void close() {
103102 logInfo ("Disconnect." );
104103 channel .close ();
105104 selector .close ();
106- } catch (IOException ioe ) {
105+ } catch (final IOException ioe ) {
107106 reportProblem ("Close socket." , ioe );
108107 logError ("Disconnect error." , ioe );
109108 }
@@ -118,7 +117,7 @@ public void send(final byte[] message) throws IOException {
118117 logError ("Attempting to write, but socket is not connected." , null );
119118 return ;
120119 }
121- byte [] outgoing = (frameOutgoing ? outgoingFramer .frame (message ) : message );
120+ final byte [] outgoing = (frameOutgoing ? outgoingFramer .frame (message ) : message );
122121
123122 logInfo ("Write " + outgoing .length + " bytes." );
124123 channel .write (ByteBuffer .wrap (outgoing ));
0 commit comments