From ee3ae043dce864e37b44f4e69813f89c1e6f7071 Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Fri, 12 Jun 2009 01:52:02 +0000 Subject: [PATCH] Fixed NPE in OioDatagramWorker.writeNow() --- .../jboss/netty/channel/socket/oio/OioDatagramWorker.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/jboss/netty/channel/socket/oio/OioDatagramWorker.java b/src/main/java/org/jboss/netty/channel/socket/oio/OioDatagramWorker.java index 4e70ec742f..7384417241 100644 --- a/src/main/java/org/jboss/netty/channel/socket/oio/OioDatagramWorker.java +++ b/src/main/java/org/jboss/netty/channel/socket/oio/OioDatagramWorker.java @@ -117,7 +117,11 @@ class OioDatagramWorker implements Runnable { ChannelBuffer a = (ChannelBuffer) message; byte[] b = new byte[a.readableBytes()]; a.getBytes(0, b); - channel.socket.send(new DatagramPacket(b, b.length, remoteAddress)); + DatagramPacket packet = new DatagramPacket(b, b.length); + if (remoteAddress != null) { + packet.setSocketAddress(remoteAddress); + } + channel.socket.send(packet); fireWriteComplete(channel, b.length); future.setSuccess(); } catch (Throwable t) {