-
Notifications
You must be signed in to change notification settings - Fork 201
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
Remove test-utility wrapper for Buffer::toString(). #51
Remove test-utility wrapper for Buffer::toString(). #51
Conversation
Signed-off-by: Joshua Marantz <jmarantz@google.com>
echo2_integration_test.cc
Outdated
@@ -35,7 +35,7 @@ TEST_P(Echo2IntegrationTest, Echo) { | |||
RawConnectionDriver connection( | |||
lookupPort("listener_0"), buffer, | |||
[&](Network::ClientConnection&, const Buffer::Instance& data) -> void { | |||
response.append(TestUtility::bufferToString(data)); | |||
response.append(Buffer::OwnedImpl(data).toString()); |
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.
Why can't toString()
just be called on data?
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.
Yeah -- this is the trick :)
In envoyproxy/envoy#3629 @htuch challenged me why we need another interface function (toString()) which is somewhat overlapping with serialize(). So I noted that removing it from the abstract interface and just having that function on BufferOwned::Impl worked (that's the way it is checked in now).
However it doesn't work to just say buffer_interface_var->toString(), even though it worked to call TestUtility::bufferToString(buffer_interface_var). The reason that worked is that OwnedImpl has an implicit constructor from const BufferInstance&, so the compiler automatically finds that.
So in envoyproxy/envoy#3736 I worked around that by adding the new interface in Buffer::Instance, but in this PR, in a different repo, I don't have that. So I help the compiler out by explicitly constructing the Buffer::OwnedImpl from the Buffer::Instance before referencing.
I could also go back to envoyproxy/envoy#3736 and remove the Buffer::Interface::toString(), and instead rely on explicit construction of an OwnedImpl in order to access its toString(). I think that happens about 10 of the 53 times this gets called in that repo. I'm fine either way.
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.
We can also just force merge this even though it doesn't pass tests, and then update the SHA here once the other thing merges. That's probably cleaner?
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.
That's fine with me too if it's OK to wind up with Buffer::Instance::toString() permanently.
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.
Sorry I don't follow. It's on the interface in your current PR. At that point, can't you just do data.toString()
?
Signed-off-by: Joshua Marantz <jmarantz@google.com>
@jmarantz just force merged, please come back and update the SHA here when the other one merges. |
No description provided.