-
-
Notifications
You must be signed in to change notification settings - Fork 15.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
codec-memcache: copy metadata in binary full request response #9160
Conversation
Can one of the admins verify this patch? |
Note: need to add license header and fix line length
On Sun, May 19, 2019 at 16:45 netty-bot ***@***.***> wrote:
Can one of the admins verify this patch?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#9160?email_source=notifications&email_token=AAXX2KLFPWIPZGYWE5P6CNTPWHRBVA5CNFSM4HN5UHLKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVXNG6Y#issuecomment-493802363>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAXX2KK2YLM5VLRQER3CGVTPWHRBVANCNFSM4HN5UHLA>
.
--
Fabien
|
@@ -0,0 +1,82 @@ | |||
/* | |||
* Copyright 2013 The Netty Project |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2019
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed
FullBinaryMemcacheRequest actual) { | ||
assertNotSame(expected, actual); | ||
|
||
assertTrue(ByteBufUtil.equals(expected.key(), actual.key())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just use assertEquals(expected.key(), actual.key()
.... same for the other lines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed
assertEquals(expected.dataType(), actual.dataType()); | ||
assertEquals(expected.totalBodyLength(), actual.totalBodyLength()); | ||
assertEquals(expected.opaque(), actual.opaque()); | ||
assertEquals(expected.cas(), actual.cas()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
call expected.release()
and actual.release()
in a finally block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting a ref count exception when running mvn test when I do that. The buffers are unpooled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm can I see the exception ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah I now see why... you sometimes pass the same buffer / request .
Just change it to when you pass in the same instance to use retainedDuplicate()
. This will ensure you will also increment the reference count
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed.
I've added some code to track what refs should be released and cleaned up in a junit @After
method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above... I would prefer if you just do it directly in the tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
@@ -0,0 +1,82 @@ | |||
/* | |||
* Copyright 2013 The Netty Project |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2019
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed
|
||
assertTrue(ByteBufUtil.equals(expected.key(), actual.key())); | ||
assertTrue(ByteBufUtil.equals(expected.extras(), actual.extras())); | ||
assertTrue(ByteBufUtil.equals(expectedContent, actual.content())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed
assertEquals(expected.totalBodyLength(), actual.totalBodyLength()); | ||
assertEquals(expected.opaque(), actual.opaque()); | ||
assertEquals(expected.cas(), actual.cas()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed
@@ -232,4 +232,15 @@ public BinaryMemcacheMessage touch(Object hint) { | |||
} | |||
return this; | |||
} | |||
|
|||
protected void copyMeta(AbstractBinaryMemcacheMessage dst) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
package-private ?
please add javadocs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed
ec87354
to
ca2db19
Compare
@netty-bot test this please |
* | ||
* @param dst The instance where to copy the metadata of this instance to | ||
*/ | ||
void copyMeta(DefaultBinaryMemcacheRequest dst) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing @Override
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no the signature of the methods are different:
super: void copyMeta(AbstractBinaryMemcacheMessage dst)
this : void copyMeta(DefaultBinaryMemcacheRequest dst)
* | ||
* @param dst The instance where to copy the metadata of this instance to | ||
*/ | ||
void copyMeta(DefaultBinaryMemcacheResponse dst) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing @Override
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no the signature of the methods are different:
super: void copyMeta(AbstractBinaryMemcacheMessage dst)
this : void copyMeta(DefaultBinaryMemcacheResponse dst)
|
||
@Before | ||
public void setUp() { | ||
refToRelease = new LinkedList<ReferenceCounted>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
honestly I think it would be a lot cleaner if you just release stuff in the tests itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure...
assertEquals(expected.dataType(), actual.dataType()); | ||
assertEquals(expected.totalBodyLength(), actual.totalBodyLength()); | ||
assertEquals(expected.opaque(), actual.opaque()); | ||
assertEquals(expected.cas(), actual.cas()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above... I would prefer if you just do it directly in the tests
Motivations ----------- Calling `copy()`, `duplicate()` or `replace()` on `FullBinaryMemcacheResponse` or `FullBinaryMemcacheRequest` instances should copy status, opCode, etc. that are defined in `AbstractBinaryMemcacheMessage`. Modifications ------------- - Modified duplicate, copy and replace methods in DefaultFullBinaryMemcacheRequest and DefaultFullBinaryMemcacheResponse to always copy metadata from parent classes. - Unit tests verifying duplicate, copy and replace methods for DefaultFullBinaryMemcacheRequest and DefaultFullBinaryMemcacheResponse copy buffers and metadata as expected. Result ------ Calling copy(), duplicate() or replace() methods on DefaultFullBinaryMemcacheRequest or DefaultFullBinaryMemcacheResponse produces valid copies with all expected metadata. Fixes netty#9159
@netty-bot test this please |
1 similar comment
@netty-bot test this please |
@fabienrenaud thanks a lot! |
Motivations ----------- Calling `copy()`, `duplicate()` or `replace()` on `FullBinaryMemcacheResponse` or `FullBinaryMemcacheRequest` instances should copy status, opCode, etc. that are defined in `AbstractBinaryMemcacheMessage`. Modifications ------------- - Modified duplicate, copy and replace methods in DefaultFullBinaryMemcacheRequest and DefaultFullBinaryMemcacheResponse to always copy metadata from parent classes. - Unit tests verifying duplicate, copy and replace methods for DefaultFullBinaryMemcacheRequest and DefaultFullBinaryMemcacheResponse copy buffers and metadata as expected. Result ------ Calling copy(), duplicate() or replace() methods on DefaultFullBinaryMemcacheRequest or DefaultFullBinaryMemcacheResponse produces valid copies with all expected metadata. Fixes #9159
Motivations
Calling
copy()
,duplicate()
orreplace()
onFullBinaryMemcacheResponse
or
FullBinaryMemcacheRequest
instances should copy status, opCode, etc.that are defined in
AbstractBinaryMemcacheMessage
.Modifications
DefaultFullBinaryMemcacheRequest and DefaultFullBinaryMemcacheResponse
to always copy metadata from parent classes.
DefaultFullBinaryMemcacheRequest and DefaultFullBinaryMemcacheResponse
copy buffers and metadata as expected.
Result
Calling copy(), duplicate() or replace() methods on
DefaultFullBinaryMemcacheRequest or DefaultFullBinaryMemcacheResponse
produces valid copies with all expected metadata.
Fixes #9159
Checklist: