Remove test-utility wrapper for Buffer::toString().#51
Remove test-utility wrapper for Buffer::toString().#51mattklein123 merged 2 commits intoenvoyproxy:masterfrom
Conversation
Signed-off-by: Joshua Marantz <jmarantz@google.com>
echo2_integration_test.cc
Outdated
| 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.
Why can't toString() just be called on data?
There was a problem hiding this comment.
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.
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.
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.
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.