Use proper buffer factory in OioWorker
Removed unnecessary local variables in OioDatagramWorker
This commit is contained in:
parent
c7c2c71935
commit
b859f120d8
@ -24,7 +24,6 @@ import java.net.SocketAddress;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.buffer.ChannelBufferFactory;
|
||||
import org.jboss.netty.channel.Channel;
|
||||
import org.jboss.netty.channel.ChannelFuture;
|
||||
import org.jboss.netty.channel.ReceiveBufferSizePredictor;
|
||||
@ -66,9 +65,6 @@ class OioDatagramWorker implements Runnable {
|
||||
|
||||
ReceiveBufferSizePredictor predictor =
|
||||
channel.getConfig().getReceiveBufferSizePredictor();
|
||||
ChannelBufferFactory bufferFactory =
|
||||
channel.getConfig().getBufferFactory();
|
||||
|
||||
|
||||
byte[] buf = new byte[predictor.nextReceiveBufferSize()];
|
||||
DatagramPacket packet = new DatagramPacket(buf, buf.length);
|
||||
@ -87,7 +83,7 @@ class OioDatagramWorker implements Runnable {
|
||||
|
||||
fireMessageReceived(
|
||||
channel,
|
||||
bufferFactory.getBuffer(buf, 0, packet.getLength()),
|
||||
channel.getConfig().getBufferFactory().getBuffer(buf, 0, packet.getLength()),
|
||||
packet.getSocketAddress());
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,6 @@ import java.nio.channels.ClosedChannelException;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.buffer.ChannelBuffers;
|
||||
import org.jboss.netty.channel.Channel;
|
||||
import org.jboss.netty.channel.ChannelFuture;
|
||||
|
||||
@ -88,15 +87,9 @@ class OioWorker implements Runnable {
|
||||
break;
|
||||
}
|
||||
|
||||
ChannelBuffer buffer;
|
||||
if (readBytes == buf.length) {
|
||||
buffer = ChannelBuffers.wrappedBuffer(buf);
|
||||
} else {
|
||||
// A rare case, but it sometimes happen.
|
||||
buffer = ChannelBuffers.wrappedBuffer(buf, 0, readBytes);
|
||||
}
|
||||
|
||||
fireMessageReceived(channel, buffer);
|
||||
fireMessageReceived(
|
||||
channel,
|
||||
channel.getConfig().getBufferFactory().getBuffer(buf, 0, readBytes));
|
||||
}
|
||||
|
||||
// Setting the workerThread to null will prevent any channel
|
||||
|
Loading…
Reference in New Issue
Block a user