From cee5f945dc4a29872591c7762dae9bfe4d100f7f Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Fri, 19 Feb 2010 00:03:33 +0000 Subject: [PATCH] Tiny code clean up --- .../jboss/netty/channel/socket/nio/NioDatagramWorker.java | 6 +++--- .../java/org/jboss/netty/channel/socket/nio/NioWorker.java | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/jboss/netty/channel/socket/nio/NioDatagramWorker.java b/src/main/java/org/jboss/netty/channel/socket/nio/NioDatagramWorker.java index 320baabfca..ae50118408 100644 --- a/src/main/java/org/jboss/netty/channel/socket/nio/NioDatagramWorker.java +++ b/src/main/java/org/jboss/netty/channel/socket/nio/NioDatagramWorker.java @@ -499,6 +499,7 @@ class NioDatagramWorker implements Runnable { int writtenBytes = 0; + final DatagramChannel ch = channel.getDatagramChannel(); final Queue writeBuffer = channel.writeBufferQueue; final int writeSpinCount = channel.getConfig().getWriteSpinCount(); synchronized (channel.writeLock) { @@ -524,11 +525,10 @@ class NioDatagramWorker implements Runnable { try { int localWrittenBytes = 0; - java.nio.channels.DatagramChannel dch = channel.getDatagramChannel(); SocketAddress raddr = evt.getRemoteAddress(); if (raddr == null) { for (int i = writeSpinCount; i > 0; i --) { - localWrittenBytes = dch.write(buf); + localWrittenBytes = ch.write(buf); if (localWrittenBytes != 0) { writtenBytes += localWrittenBytes; break; @@ -536,7 +536,7 @@ class NioDatagramWorker implements Runnable { } } else { for (int i = writeSpinCount; i > 0; i --) { - localWrittenBytes = dch.send(buf, raddr); + localWrittenBytes = ch.send(buf, raddr); if (localWrittenBytes != 0) { writtenBytes += localWrittenBytes; break; diff --git a/src/main/java/org/jboss/netty/channel/socket/nio/NioWorker.java b/src/main/java/org/jboss/netty/channel/socket/nio/NioWorker.java index ef78a2f236..ffae6792db 100644 --- a/src/main/java/org/jboss/netty/channel/socket/nio/NioWorker.java +++ b/src/main/java/org/jboss/netty/channel/socket/nio/NioWorker.java @@ -24,9 +24,9 @@ import java.nio.channels.AsynchronousCloseException; import java.nio.channels.CancelledKeyException; import java.nio.channels.ClosedChannelException; import java.nio.channels.NotYetConnectedException; -import java.nio.channels.ScatteringByteChannel; import java.nio.channels.SelectionKey; import java.nio.channels.Selector; +import java.nio.channels.SocketChannel; import java.util.Iterator; import java.util.Queue; import java.util.Set; @@ -304,7 +304,7 @@ class NioWorker implements Runnable { } private boolean read(SelectionKey k) { - ScatteringByteChannel ch = (ScatteringByteChannel) k.channel(); + SocketChannel ch = (SocketChannel) k.channel(); NioSocketChannel channel = (NioSocketChannel) k.attachment(); ReceiveBufferSizePredictor predictor = @@ -452,6 +452,7 @@ class NioWorker implements Runnable { int writtenBytes = 0; + final SocketChannel ch = channel.socket; final Queue writeBuffer = channel.writeBuffer; final int writeSpinCount = channel.getConfig().getWriteSpinCount(); synchronized (channel.writeLock) { @@ -474,7 +475,7 @@ class NioWorker implements Runnable { try { for (int i = writeSpinCount; i > 0; i --) { - int localWrittenBytes = channel.socket.write(buf); + int localWrittenBytes = ch.write(buf); if (localWrittenBytes != 0) { writtenBytes += localWrittenBytes; break;