Fix buffer leak in DefaultFullBinaryMemcacheRequest/Response

Motivation:

DefaultFullBinaryMemcacheRequest/Response overrides release(), retain(),
and touch() methods without calling its super, resulting in a leak of
the extras.

Modifications:

When overriding release(), retain(), and touch(), ensure to call super.

Result:

Fixes #2533 by fixing the buffer leak
This commit is contained in:
Trustin Lee 2014-06-24 15:04:50 +09:00
parent daa58f74e7
commit 2f650fdab7
2 changed files with 32 additions and 4 deletions

View File

@ -65,45 +65,59 @@ public class DefaultFullBinaryMemcacheRequest extends DefaultBinaryMemcacheReque
@Override
public FullBinaryMemcacheRequest retain() {
super.retain();
content.retain();
return this;
}
@Override
public FullBinaryMemcacheRequest retain(int increment) {
super.retain(increment);
content.retain(increment);
return this;
}
@Override
public FullBinaryMemcacheRequest touch() {
super.touch();
content.touch();
return this;
}
@Override
public FullBinaryMemcacheRequest touch(Object hint) {
super.touch(hint);
content.touch(hint);
return this;
}
@Override
public boolean release() {
super.release();
return content.release();
}
@Override
public boolean release(int decrement) {
super.release(decrement);
return content.release(decrement);
}
@Override
public FullBinaryMemcacheRequest copy() {
return new DefaultFullBinaryMemcacheRequest(getKey(), getExtras(), content().copy());
ByteBuf extras = getExtras();
if (extras != null) {
extras = extras.copy();
}
return new DefaultFullBinaryMemcacheRequest(getKey(), extras, content().copy());
}
@Override
public FullBinaryMemcacheRequest duplicate() {
return new DefaultFullBinaryMemcacheRequest(getKey(), getExtras(), content().duplicate());
ByteBuf extras = getExtras();
if (extras != null) {
extras = extras.duplicate();
}
return new DefaultFullBinaryMemcacheRequest(getKey(), extras, content().duplicate());
}
}

View File

@ -65,45 +65,59 @@ public class DefaultFullBinaryMemcacheResponse extends DefaultBinaryMemcacheResp
@Override
public FullBinaryMemcacheResponse retain() {
super.retain();
content.retain();
return this;
}
@Override
public FullBinaryMemcacheResponse retain(int increment) {
super.retain(increment);
content.retain(increment);
return this;
}
@Override
public FullBinaryMemcacheResponse touch() {
super.touch();
content.touch();
return this;
}
@Override
public FullBinaryMemcacheResponse touch(Object hint) {
super.touch(hint);
content.touch(hint);
return this;
}
@Override
public boolean release() {
super.release();
return content.release();
}
@Override
public boolean release(int decrement) {
super.release(decrement);
return content.release(decrement);
}
@Override
public FullBinaryMemcacheResponse copy() {
return new DefaultFullBinaryMemcacheResponse(getKey(), getExtras(), content().copy());
ByteBuf extras = getExtras();
if (extras != null) {
extras = extras.copy();
}
return new DefaultFullBinaryMemcacheResponse(getKey(), extras, content().copy());
}
@Override
public FullBinaryMemcacheResponse duplicate() {
return new DefaultFullBinaryMemcacheResponse(getKey(), getExtras(), content().duplicate());
ByteBuf extras = getExtras();
if (extras != null) {
extras = extras.duplicate();
}
return new DefaultFullBinaryMemcacheResponse(getKey(), extras, content().duplicate());
}
}