本文整理汇总了Java中io.netty.util.IllegalReferenceCountException类的典型用法代码示例。如果您正苦于以下问题:Java IllegalReferenceCountException类的具体用法?Java IllegalReferenceCountException怎么用?Java IllegalReferenceCountException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IllegalReferenceCountException类属于io.netty.util包,在下文中一共展示了IllegalReferenceCountException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: release0
import io.netty.util.IllegalReferenceCountException; //导入依赖的package包/类
private boolean release0(int decrement) {
for (;;) {
int refCnt = this.refCnt;
if (refCnt < decrement) {
throw new IllegalReferenceCountException(refCnt, -decrement);
}
if (refCntUpdater.compareAndSet(this, refCnt, refCnt - decrement)) {
if (refCnt == decrement) {
deallocate();
return true;
}
return false;
}
}
}
示例2: release
import io.netty.util.IllegalReferenceCountException; //导入依赖的package包/类
@Override
public final boolean release(int decrement) {
if (decrement <= 0) {
throw new IllegalArgumentException("decrement: " + decrement + " (expected: > 0)");
}
for (;;) {
int refCnt = this.refCnt;
if (refCnt < decrement) {
throw new IllegalReferenceCountException(refCnt, -decrement);
}
if (refCntUpdater.compareAndSet(this, refCnt, refCnt - decrement)) {
if (refCnt == decrement) {
deallocate();
return true;
}
return false;
}
}
}
示例3: content
import io.netty.util.IllegalReferenceCountException; //导入依赖的package包/类
@Override
public ByteBuf content() {
final ByteBuf data = (ByteBuf) super.payload();
if (data.refCnt() <= 0) {
throw new IllegalReferenceCountException(data.refCnt());
}
return data;
}
示例4: exceptionCaught
import io.netty.util.IllegalReferenceCountException; //导入依赖的package包/类
/**
* {@inheritDoc}
* @see io.netty.channel.ChannelInboundHandlerAdapter#exceptionCaught(io.netty.channel.ChannelHandlerContext, java.lang.Throwable)
*/
@Override
public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause) throws Exception {
final Channel chan = ctx.channel();
if (cause instanceof ClosedChannelException) {
exceptions_closed.inc();
log.warn("Attempt to write to closed channel " + chan);
return;
} else if(cause instanceof IllegalReferenceCountException) {
log.warn("BadRefCount: [{}]", cause.getMessage());
} else if (cause instanceof IOException) {
final String message = cause.getMessage();
if ("Connection reset by peer".equals(message)) {
exceptions_reset.inc();
return;
} else if ("Connection timed out".equals(message)) {
exceptions_timeout.inc();
// Do nothing. A client disconnecting isn't really our problem. Oh,
// and I'm not kidding you, there's no better way to detect ECONNRESET
// in Java. Like, people have been bitching about errno for years,
// and Java managed to do something *far* worse. That's quite a feat.
return;
}
}
// FIXME: not sure what the netty 4 is for this
//if (cause instanceof CodecEmbedderException) {
// // payload was not compressed as it was announced to be
// log.warn("Http codec error : " + cause.getMessage());
// e.getChannel().close();
// return;
//}
exceptions_unknown.inc();
log.error("Unexpected exception from downstream for " + chan, cause);
chan.close();
}
示例5: content
import io.netty.util.IllegalReferenceCountException; //导入依赖的package包/类
@Override
public ByteBuf content() {
if (data.refCnt() <= 0) {
throw new IllegalReferenceCountException(data.refCnt());
}
return data;
}
示例6: testArrayAfterRelease
import io.netty.util.IllegalReferenceCountException; //导入依赖的package包/类
@Test
public void testArrayAfterRelease() {
ByteBuf buf = releasedBuffer();
if (buf.hasArray()) {
try {
buf.array();
fail();
} catch (IllegalReferenceCountException e) {
// expected
}
}
}
示例7: testMemoryAddressAfterRelease
import io.netty.util.IllegalReferenceCountException; //导入依赖的package包/类
@Test
public void testMemoryAddressAfterRelease() {
ByteBuf buf = releasedBuffer();
if (buf.hasMemoryAddress()) {
try {
buf.memoryAddress();
fail();
} catch (IllegalReferenceCountException e) {
// expected
}
}
}
示例8: assertAccessible
import io.netty.util.IllegalReferenceCountException; //导入依赖的package包/类
private void assertAccessible() {
if (refCnt() == 0) throw new IllegalReferenceCountException(0);
}
示例9: assertValid
import io.netty.util.IllegalReferenceCountException; //导入依赖的package包/类
private void assertValid() {
if (refCnt() <= 0) throw new IllegalReferenceCountException("Packet deallocated");
}
示例10: testGetBytesAfterRelease7
import io.netty.util.IllegalReferenceCountException; //导入依赖的package包/类
@Test(expected = IllegalReferenceCountException.class)
public void testGetBytesAfterRelease7() throws IOException {
releasedBuffer().getBytes(0, new ByteArrayOutputStream(), 1);
}
示例11: testReadUnsignedMediumAfterRelease
import io.netty.util.IllegalReferenceCountException; //导入依赖的package包/类
@Test(expected = IllegalReferenceCountException.class)
public void testReadUnsignedMediumAfterRelease() {
releasedBuffer().readUnsignedMedium();
}
示例12: testEnsureWritableAfterRelease
import io.netty.util.IllegalReferenceCountException; //导入依赖的package包/类
@Test(expected = IllegalReferenceCountException.class)
public void testEnsureWritableAfterRelease() {
releasedBuffer().ensureWritable(16);
}
示例13: testSetBytesAfterRelease
import io.netty.util.IllegalReferenceCountException; //导入依赖的package包/类
@Test(expected = IllegalReferenceCountException.class)
public void testSetBytesAfterRelease() {
releasedBuffer().setBytes(0, releaseLater(buffer()));
}
示例14: testWriteFloatAfterRelease
import io.netty.util.IllegalReferenceCountException; //导入依赖的package包/类
@Test(expected = IllegalReferenceCountException.class)
public void testWriteFloatAfterRelease() {
releasedBuffer().writeFloat(1);
}
示例15: testGetUnsignedByteAfterRelease
import io.netty.util.IllegalReferenceCountException; //导入依赖的package包/类
@Test(expected = IllegalReferenceCountException.class)
public void testGetUnsignedByteAfterRelease() {
releasedBuffer().getUnsignedByte(0);
}