diff --git a/buffer/src/main/java/io/netty/buffer/ByteBufUtil.java b/buffer/src/main/java/io/netty/buffer/ByteBufUtil.java index 8ca9ad69cc..f463a4d495 100644 --- a/buffer/src/main/java/io/netty/buffer/ByteBufUtil.java +++ b/buffer/src/main/java/io/netty/buffer/ByteBufUtil.java @@ -16,8 +16,6 @@ package io.netty.buffer; import io.netty.util.CharsetUtil; -import io.netty.util.ReferenceCountUtil; -import io.netty.util.ReferenceCounted; import java.nio.ByteBuffer; import java.nio.ByteOrder; @@ -43,52 +41,6 @@ public final class ByteBufUtil { } } - /** - * Try to call {@link ReferenceCounted#retain()} if the specified message implements {@link ReferenceCounted}. - * If the specified message doesn't implement {@link ReferenceCounted}, this method does nothing. - * - * @deprecated use {@link ReferenceCountUtil#retain(Object)} - */ - @SuppressWarnings("unchecked") - @Deprecated - public static T retain(T msg) { - return ReferenceCountUtil.retain(msg); - } - - /** - * Try to call {@link ReferenceCounted#retain()} if the specified message implements {@link ReferenceCounted}. - * If the specified message doesn't implement {@link ReferenceCounted}, this method does nothing. - * - * @deprecated use {@link ReferenceCountUtil#retain(Object, int)} - */ - @SuppressWarnings("unchecked") - @Deprecated - public static T retain(T msg, int increment) { - return ReferenceCountUtil.retain(msg, increment); - } - - /** - * Try to call {@link ReferenceCounted#release()} if the specified message implements {@link ReferenceCounted}. - * If the specified message doesn't implement {@link ReferenceCounted}, this method does nothing. - * - * @deprecated use {@link ReferenceCountUtil#release(Object)} - */ - @Deprecated - public static boolean release(Object msg) { - return ReferenceCountUtil.release(msg); - } - - /** - * Try to call {@link ReferenceCounted#release()} if the specified message implements {@link ReferenceCounted}. - * If the specified message doesn't implement {@link ReferenceCounted}, this method does nothing. - * - * @deprecated use {@link ReferenceCountUtil#release(Object, int)} - */ - @Deprecated - public static boolean release(Object msg, int decrement) { - return ReferenceCountUtil.release(msg, decrement); - } - /** * Returns a hex dump * of the specified buffer's readable bytes. diff --git a/transport/src/main/java/io/netty/channel/socket/nio/NioDatagramChannel.java b/transport/src/main/java/io/netty/channel/socket/nio/NioDatagramChannel.java index def2ea368a..1c98316afa 100755 --- a/transport/src/main/java/io/netty/channel/socket/nio/NioDatagramChannel.java +++ b/transport/src/main/java/io/netty/channel/socket/nio/NioDatagramChannel.java @@ -17,7 +17,6 @@ package io.netty.channel.socket.nio; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufHolder; -import io.netty.buffer.ByteBufUtil; import io.netty.channel.AddressedEnvelope; import io.netty.channel.Channel; import io.netty.channel.ChannelException; @@ -30,6 +29,7 @@ import io.netty.channel.nio.AbstractNioMessageChannel; import io.netty.channel.socket.DatagramChannelConfig; import io.netty.channel.socket.DatagramPacket; import io.netty.channel.socket.InternetProtocolFamily; +import io.netty.util.ReferenceCountUtil; import io.netty.util.internal.PlatformDependent; import io.netty.util.internal.StringUtil; @@ -255,8 +255,7 @@ public final class NioDatagramChannel } else if (m instanceof ByteBuf) { data = (ByteBuf) m; } else { - ByteBufUtil.release(o); - throw new ChannelException("unsupported message type: " + StringUtil.simpleClassName(o)); + throw new UnsupportedOperationException("unsupported message type: " + StringUtil.simpleClassName(0)); } int dataLen = data.readableBytes(); @@ -293,7 +292,7 @@ public final class NioDatagramChannel } // Wrote a packet - free the message. - ByteBufUtil.release(o); + ReferenceCountUtil.release(o); if (index + 1 == msgs.size()) { // Wrote the outbound buffer completely - clear OP_WRITE. diff --git a/transport/src/main/java/io/netty/channel/socket/oio/OioDatagramChannel.java b/transport/src/main/java/io/netty/channel/socket/oio/OioDatagramChannel.java index 1d329105e7..54a69e84d4 100755 --- a/transport/src/main/java/io/netty/channel/socket/oio/OioDatagramChannel.java +++ b/transport/src/main/java/io/netty/channel/socket/oio/OioDatagramChannel.java @@ -17,7 +17,6 @@ package io.netty.channel.socket.oio; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufHolder; -import io.netty.buffer.ByteBufUtil; import io.netty.channel.AddressedEnvelope; import io.netty.channel.Channel; import io.netty.channel.ChannelException; @@ -31,6 +30,7 @@ import io.netty.channel.socket.DatagramChannel; import io.netty.channel.socket.DatagramChannelConfig; import io.netty.channel.socket.DatagramPacket; import io.netty.channel.socket.DefaultDatagramChannelConfig; +import io.netty.util.ReferenceCountUtil; import io.netty.util.internal.EmptyArrays; import io.netty.util.internal.PlatformDependent; import io.netty.util.internal.StringUtil; @@ -263,27 +263,23 @@ public class OioDatagramChannel extends AbstractOioMessageChannel } else if (m instanceof ByteBuf) { data = (ByteBuf) m; } else { - ByteBufUtil.release(o); - throw new ChannelException("unsupported message type: " + StringUtil.simpleClassName(o)); + throw new UnsupportedOperationException("unsupported message type: " + StringUtil.simpleClassName(o)); } - try { - int length = data.readableBytes(); - if (remoteAddress != null) { - tmpPacket.setSocketAddress(remoteAddress); - } - if (data.hasArray()) { - tmpPacket.setData(data.array(), data.arrayOffset() + data.readerIndex(), length); - } else { - byte[] tmp = new byte[length]; - data.getBytes(data.readerIndex(), tmp); - tmpPacket.setData(tmp); - } - socket.send(tmpPacket); - return 1; - } finally { - ByteBufUtil.release(o); + int length = data.readableBytes(); + if (remoteAddress != null) { + tmpPacket.setSocketAddress(remoteAddress); } + if (data.hasArray()) { + tmpPacket.setData(data.array(), data.arrayOffset() + data.readerIndex(), length); + } else { + byte[] tmp = new byte[length]; + data.getBytes(data.readerIndex(), tmp); + tmpPacket.setData(tmp); + } + socket.send(tmpPacket); + ReferenceCountUtil.release(o); + return 1; } @Override