ReferenceCountException -> IllegalReferenceCountException

This commit is contained in:
Trustin Lee 2013-06-13 14:00:15 +09:00
parent 7eb0f6105d
commit 6d1cd0d0cd
7 changed files with 26 additions and 27 deletions

View File

@ -15,7 +15,7 @@
*/ */
package io.netty.buffer; package io.netty.buffer;
import io.netty.util.ReferenceCountException; import io.netty.util.IllegalReferenceCountException;
import io.netty.util.ResourceLeakDetector; import io.netty.util.ResourceLeakDetector;
import java.io.IOException; import java.io.IOException;
@ -1134,7 +1134,7 @@ public abstract class AbstractByteBuf implements ByteBuf {
*/ */
protected final void ensureAccessible() { protected final void ensureAccessible() {
if (refCnt() == 0) { if (refCnt() == 0) {
throw new ReferenceCountException(0); throw new IllegalReferenceCountException(0);
} }
} }
} }

View File

@ -16,7 +16,7 @@
package io.netty.buffer; package io.netty.buffer;
import io.netty.util.ReferenceCountException; import io.netty.util.IllegalReferenceCountException;
import io.netty.util.internal.PlatformDependent; import io.netty.util.internal.PlatformDependent;
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
@ -74,10 +74,10 @@ public abstract class AbstractReferenceCountedByteBuf extends AbstractByteBuf {
for (;;) { for (;;) {
int refCnt = this.refCnt; int refCnt = this.refCnt;
if (refCnt == 0) { if (refCnt == 0) {
throw new ReferenceCountException(0, 1); throw new IllegalReferenceCountException(0, 1);
} }
if (refCnt == Integer.MAX_VALUE) { if (refCnt == Integer.MAX_VALUE) {
throw new ReferenceCountException(Integer.MAX_VALUE, 1); throw new IllegalReferenceCountException(Integer.MAX_VALUE, 1);
} }
if (refCntUpdater.compareAndSet(this, refCnt, refCnt + 1)) { if (refCntUpdater.compareAndSet(this, refCnt, refCnt + 1)) {
break; break;
@ -95,10 +95,10 @@ public abstract class AbstractReferenceCountedByteBuf extends AbstractByteBuf {
for (;;) { for (;;) {
int refCnt = this.refCnt; int refCnt = this.refCnt;
if (refCnt == 0) { if (refCnt == 0) {
throw new ReferenceCountException(0, increment); throw new IllegalReferenceCountException(0, increment);
} }
if (refCnt > Integer.MAX_VALUE - increment) { if (refCnt > Integer.MAX_VALUE - increment) {
throw new ReferenceCountException(refCnt, increment); throw new IllegalReferenceCountException(refCnt, increment);
} }
if (refCntUpdater.compareAndSet(this, refCnt, refCnt + increment)) { if (refCntUpdater.compareAndSet(this, refCnt, refCnt + increment)) {
break; break;
@ -112,7 +112,7 @@ public abstract class AbstractReferenceCountedByteBuf extends AbstractByteBuf {
for (;;) { for (;;) {
int refCnt = this.refCnt; int refCnt = this.refCnt;
if (refCnt == 0) { if (refCnt == 0) {
throw new ReferenceCountException(0, -1); throw new IllegalReferenceCountException(0, -1);
} }
if (refCntUpdater.compareAndSet(this, refCnt, refCnt - 1)) { if (refCntUpdater.compareAndSet(this, refCnt, refCnt - 1)) {
@ -134,7 +134,7 @@ public abstract class AbstractReferenceCountedByteBuf extends AbstractByteBuf {
for (;;) { for (;;) {
int refCnt = this.refCnt; int refCnt = this.refCnt;
if (refCnt < decrement) { if (refCnt < decrement) {
throw new ReferenceCountException(refCnt, -decrement); throw new IllegalReferenceCountException(refCnt, -decrement);
} }
if (refCntUpdater.compareAndSet(this, refCnt, refCnt - decrement)) { if (refCntUpdater.compareAndSet(this, refCnt, refCnt - decrement)) {

View File

@ -15,7 +15,7 @@
*/ */
package io.netty.buffer; package io.netty.buffer;
import io.netty.util.ReferenceCountException; import io.netty.util.IllegalReferenceCountException;
/** /**
* Default implementation of a {@link ByteBufHolder} that holds it's data in a {@link ByteBuf}. * Default implementation of a {@link ByteBufHolder} that holds it's data in a {@link ByteBuf}.
@ -35,7 +35,7 @@ public class DefaultByteBufHolder implements ByteBufHolder {
@Override @Override
public ByteBuf content() { public ByteBuf content() {
if (data.refCnt() <= 0) { if (data.refCnt() <= 0) {
throw new ReferenceCountException(data.refCnt()); throw new IllegalReferenceCountException(data.refCnt());
} }
return data; return data;
} }

View File

@ -17,7 +17,7 @@ package io.netty.handler.codec.spdy;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled; import io.netty.buffer.Unpooled;
import io.netty.util.ReferenceCountException; import io.netty.util.IllegalReferenceCountException;
import io.netty.util.internal.StringUtil; import io.netty.util.internal.StringUtil;
/** /**
@ -73,7 +73,7 @@ public class DefaultSpdyDataFrame extends DefaultSpdyStreamFrame implements Spdy
@Override @Override
public ByteBuf content() { public ByteBuf content() {
if (data.refCnt() <= 0) { if (data.refCnt() <= 0) {
throw new ReferenceCountException(data.refCnt()); throw new IllegalReferenceCountException(data.refCnt());
} }
return data; return data;
} }

View File

@ -16,7 +16,6 @@
package io.netty.handler.codec.frame; package io.netty.handler.codec.frame;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.channel.IncompleteFlushException;
import io.netty.channel.embedded.EmbeddedChannel; import io.netty.channel.embedded.EmbeddedChannel;
import io.netty.handler.codec.EncoderException; import io.netty.handler.codec.EncoderException;
import io.netty.handler.codec.LengthFieldPrepender; import io.netty.handler.codec.LengthFieldPrepender;

View File

@ -68,10 +68,10 @@ public abstract class AbstractReferenceCounted implements ReferenceCounted {
for (;;) { for (;;) {
int refCnt = this.refCnt; int refCnt = this.refCnt;
if (refCnt == 0) { if (refCnt == 0) {
throw new ReferenceCountException(0, 1); throw new IllegalReferenceCountException(0, 1);
} }
if (refCnt == Integer.MAX_VALUE) { if (refCnt == Integer.MAX_VALUE) {
throw new ReferenceCountException(Integer.MAX_VALUE, 1); throw new IllegalReferenceCountException(Integer.MAX_VALUE, 1);
} }
if (refCntUpdater.compareAndSet(this, refCnt, refCnt + 1)) { if (refCntUpdater.compareAndSet(this, refCnt, refCnt + 1)) {
break; break;
@ -89,10 +89,10 @@ public abstract class AbstractReferenceCounted implements ReferenceCounted {
for (;;) { for (;;) {
int refCnt = this.refCnt; int refCnt = this.refCnt;
if (refCnt == 0) { if (refCnt == 0) {
throw new ReferenceCountException(0, 1); throw new IllegalReferenceCountException(0, 1);
} }
if (refCnt > Integer.MAX_VALUE - increment) { if (refCnt > Integer.MAX_VALUE - increment) {
throw new ReferenceCountException(refCnt, increment); throw new IllegalReferenceCountException(refCnt, increment);
} }
if (refCntUpdater.compareAndSet(this, refCnt, refCnt + increment)) { if (refCntUpdater.compareAndSet(this, refCnt, refCnt + increment)) {
break; break;
@ -106,7 +106,7 @@ public abstract class AbstractReferenceCounted implements ReferenceCounted {
for (;;) { for (;;) {
int refCnt = this.refCnt; int refCnt = this.refCnt;
if (refCnt == 0) { if (refCnt == 0) {
throw new ReferenceCountException(0, -1); throw new IllegalReferenceCountException(0, -1);
} }
if (refCntUpdater.compareAndSet(this, refCnt, refCnt - 1)) { if (refCntUpdater.compareAndSet(this, refCnt, refCnt - 1)) {
@ -128,7 +128,7 @@ public abstract class AbstractReferenceCounted implements ReferenceCounted {
for (;;) { for (;;) {
int refCnt = this.refCnt; int refCnt = this.refCnt;
if (refCnt < decrement) { if (refCnt < decrement) {
throw new ReferenceCountException(refCnt, -decrement); throw new IllegalReferenceCountException(refCnt, -decrement);
} }
if (refCntUpdater.compareAndSet(this, refCnt, refCnt - decrement)) { if (refCntUpdater.compareAndSet(this, refCnt, refCnt - decrement)) {

View File

@ -20,29 +20,29 @@ package io.netty.util;
* An {@link IllegalStateException} which is raised when a user attempts to access a {@link ReferenceCounted} whose * An {@link IllegalStateException} which is raised when a user attempts to access a {@link ReferenceCounted} whose
* reference count has been decreased to 0 (and consequently freed). * reference count has been decreased to 0 (and consequently freed).
*/ */
public class ReferenceCountException extends IllegalStateException { public class IllegalReferenceCountException extends IllegalStateException {
private static final long serialVersionUID = -2507492394288153468L; private static final long serialVersionUID = -2507492394288153468L;
public ReferenceCountException() { } public IllegalReferenceCountException() { }
public ReferenceCountException(int refCnt) { public IllegalReferenceCountException(int refCnt) {
this("refCnt: " + refCnt); this("refCnt: " + refCnt);
} }
public ReferenceCountException(int refCnt, int increment) { public IllegalReferenceCountException(int refCnt, int increment) {
this("refCnt: " + refCnt + ", " + (increment > 0? "increment: " + increment : "decrement: " + -increment)); this("refCnt: " + refCnt + ", " + (increment > 0? "increment: " + increment : "decrement: " + -increment));
} }
public ReferenceCountException(String message) { public IllegalReferenceCountException(String message) {
super(message); super(message);
} }
public ReferenceCountException(String message, Throwable cause) { public IllegalReferenceCountException(String message, Throwable cause) {
super(message, cause); super(message, cause);
} }
public ReferenceCountException(Throwable cause) { public IllegalReferenceCountException(Throwable cause) {
super(cause); super(cause);
} }
} }