Skip to content

Commit

Permalink
Add ReferenceCounted.touch() / Add missing retain() overrides
Browse files Browse the repository at this point in the history
- Fixes netty#2163
- Inspector warnings
  • Loading branch information
trustin committed Jan 28, 2014
1 parent 928901c commit b887e35
Show file tree
Hide file tree
Showing 72 changed files with 450 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ public final ByteBuf retain(int increment) {
return this;
}

@Override
public final ByteBuf touch() {
unwrap().touch();
return this;
}

@Override
public final boolean release() {
return unwrap().release();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ public ByteBuf retain(int increment) {
return this;
}

@Override
public final ByteBuf touch() {
return this;
}

@Override
public final boolean release() {
for (;;) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,12 @@ public ByteBuf retain(int increment) {
return super.retain(increment);
}

@Override
public ByteBuf touch() {
leak.record();
return this;
}

@Override
public ByteBuf capacity(int newCapacity) {
leak.record();
Expand Down
3 changes: 3 additions & 0 deletions buffer/src/main/java/io/netty/buffer/ByteBuf.java
Original file line number Diff line number Diff line change
Expand Up @@ -1877,4 +1877,7 @@ public abstract class ByteBuf implements ReferenceCounted, Comparable<ByteBuf> {

@Override
public abstract ByteBuf retain();

@Override
public abstract ByteBuf touch();
}
3 changes: 3 additions & 0 deletions buffer/src/main/java/io/netty/buffer/ByteBufHolder.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,7 @@ public interface ByteBufHolder extends ReferenceCounted {

@Override
ByteBufHolder retain(int increment);

@Override
ByteBufHolder touch();
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ public ByteBufHolder retain(int increment) {
return this;
}

@Override
public ByteBufHolder touch() {
data.touch();
return this;
}

@Override
public boolean release() {
return data.release();
Expand Down
5 changes: 5 additions & 0 deletions buffer/src/main/java/io/netty/buffer/EmptyByteBuf.java
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,11 @@ public ByteBuf retain(int increment) {
return this;
}

@Override
public ByteBuf touch() {
return this;
}

@Override
public boolean release() {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ final class SimpleLeakAwareByteBuf extends WrappedByteBuf {
this.leak = leak;
}

@Override
public ByteBuf touch() {
return this;
}

@Override
public boolean release() {
boolean deallocated = super.release();
Expand Down
8 changes: 7 additions & 1 deletion buffer/src/main/java/io/netty/buffer/SwappedByteBuf.java
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,12 @@ public ByteBuf retain(int increment) {
return this;
}

@Override
public ByteBuf touch() {
buf.touch();
return this;
}

@Override
public boolean release() {
return buf.release();
Expand Down Expand Up @@ -847,6 +853,6 @@ public int compareTo(ByteBuf buffer) {

@Override
public String toString() {
return "Swapped(" + buf.toString() + ')';
return "Swapped(" + buf + ')';
}
}
5 changes: 5 additions & 0 deletions buffer/src/main/java/io/netty/buffer/UnreleasableByteBuf.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ public ByteBuf retain() {
return this;
}

@Override
public ByteBuf touch() {
return this;
}

@Override
public boolean release() {
return false;
Expand Down
6 changes: 6 additions & 0 deletions buffer/src/main/java/io/netty/buffer/WrappedByteBuf.java
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,12 @@ public ByteBuf retain() {
return this;
}

@Override
public ByteBuf touch() {
buf.touch();
return this;
}

@Override
public boolean isReadable(int size) {
return buf.isReadable(size);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ public LastHttpContent retain() {
return this;
}

@Override
public LastHttpContent touch() {
return this;
}

@Override
public LastHttpContent duplicate() {
return copy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ public FullHttpRequest retain(int increment) {
return this;
}

@Override
public FullHttpRequest touch() {
content.touch();
return this;
}

@Override
public boolean release() {
return content.release();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ public FullHttpResponse retain(int increment) {
return this;
}

@Override
public FullHttpResponse touch() {
content.touch();
return this;
}

@Override
public boolean release() {
return content.release();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ public HttpContent retain(int increment) {
return this;
}

@Override
public HttpContent touch() {
content.touch();
return this;
}

@Override
public boolean release() {
return content.release();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ public LastHttpContent retain() {
return this;
}

@Override
public LastHttpContent touch() {
super.touch();
return this;
}

@Override
public HttpHeaders trailingHeaders() {
return trailingHeaders;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public interface FullHttpMessage extends HttpMessage, LastHttpContent {
@Override
FullHttpMessage retain();

@Override
FullHttpMessage touch();

@Override
FullHttpMessage duplicate();
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public interface FullHttpRequest extends HttpRequest, FullHttpMessage {
@Override
FullHttpRequest retain();

@Override
FullHttpRequest touch();

@Override
FullHttpRequest duplicate();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public interface FullHttpResponse extends HttpResponse, FullHttpMessage {
@Override
FullHttpResponse retain();

@Override
FullHttpResponse touch();

@Override
FullHttpResponse duplicate();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,7 @@ public interface HttpContent extends HttpObject, ByteBufHolder {

@Override
HttpContent retain(int increment);

@Override
HttpContent touch();
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ public LastHttpContent retain(int increment) {
return this;
}

@Override
public LastHttpContent touch() {
return this;
}

@Override
public boolean release() {
return false;
Expand Down Expand Up @@ -101,6 +106,9 @@ public String toString() {
@Override
LastHttpContent retain();

@Override
LastHttpContent touch();

@Override
LastHttpContent duplicate();
}
Original file line number Diff line number Diff line change
Expand Up @@ -396,4 +396,9 @@ private static byte[] readFrom(File src) throws IOException {
public File getFile() throws IOException {
return file;
}

@Override
public HttpData touch() {
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,7 @@ public HttpData retain(int increment) {
super.retain(increment);
return this;
}

@Override
public abstract HttpData touch();
}
Original file line number Diff line number Diff line change
Expand Up @@ -257,4 +257,12 @@ public boolean renameTo(File dest) throws IOException {
public File getFile() throws IOException {
throw new IOException("Not represented by a file");
}

@Override
public HttpData touch() {
if (byteBuf != null) {
byteBuf.touch();
}
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,7 @@ public interface Attribute extends HttpData {

@Override
Attribute retain(int increment);

@Override
Attribute touch();
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public String toString() {
try {
return getName() + '=' + getValue();
} catch (IOException e) {
return getName() + "=IoException";
return getName() + '=' + e;
}
}

Expand Down Expand Up @@ -192,4 +192,10 @@ public Attribute retain() {
super.retain();
return this;
}

@Override
public Attribute touch() {
super.touch();
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -211,4 +211,10 @@ public FileUpload retain() {
super.retain();
return this;
}

@Override
public FileUpload touch() {
super.touch();
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,7 @@ public interface FileUpload extends HttpData {

@Override
FileUpload retain(int increment);

@Override
FileUpload touch();
}
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,7 @@ public interface HttpData extends InterfaceHttpData, ByteBufHolder {

@Override
HttpData retain(int increment);

@Override
HttpData touch();
}
Original file line number Diff line number Diff line change
Expand Up @@ -1161,6 +1161,7 @@ public void setDecoderResult(DecoderResult result) {

private static final class WrappedFullHttpRequest extends WrappedHttpRequest implements FullHttpRequest {
private final HttpContent content;

private WrappedFullHttpRequest(HttpRequest request, HttpContent content) {
super(request);
this.content = content;
Expand Down Expand Up @@ -1214,6 +1215,12 @@ public FullHttpRequest retain() {
return this;
}

@Override
public FullHttpRequest touch() {
content.touch();
return this;
}

@Override
public ByteBuf content() {
return content.content();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,13 @@ enum HttpDataType {
* @return The HttpDataType
*/
HttpDataType getHttpDataType();

@Override
InterfaceHttpData retain();

@Override
InterfaceHttpData retain(int increment);

@Override
InterfaceHttpData touch();
}
Loading

0 comments on commit b887e35

Please sign in to comment.