-
Notifications
You must be signed in to change notification settings - Fork 15.5k
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
Implement the done method on JsonObjectWriter #5939
Conversation
Not sure whether there's any restriction in c++ for adding public API |
What is the rationale of this change? These are internal interfaces (inside the |
It's used extensively in https://github.com/grpc-ecosystem/grpc-httpjson-transcoding (sad but true) and I have a change to that which wants to be able to use a JsonObjectWriter as an ObjectWriter. |
ping? |
I can take over reviewing since Josh is on vacation. |
I am still not a fan of making changes to internal-only interfaces to support users who are calling them directly. These interfaces could (and in my opinion, should) disappear completely in a future release. This is way more API surface area than we want to be supporting officially. Why is the transcoding package using these interfaces and how can they be migrated off? |
@haberman I think you would have to talk to the grpc team about that. I can't check these days, but I'm guessing the answer is on the google3 side (although it might just be http://www.hyrumslaw.com/) I do note that you have //visibility:public on all headers, so it's never really been internal-only and will probably need an LSC to change that: Lines 222 to 229 in d2d6ff5
|
@haberman I suspect that JsonObjectWriter is actually supposed to be public. Within Google it's in a subdirectory called |
@asuffield The failing test is reporting some memory leaks in the new test cases. I don't see any obvious leak but do you have any ideas what the problem is? |
I strongly disagree. This code was only open-sourced to support the public functionality in https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/util/json_util.h We (as the protobuf team) wanted to open-source JSON <-> protobuf functions for proto3. These are simple string->string functions ( Internally these functions use the We are very careful about what interfaces we publicly expose (in open-source), because our burden of backward compatibility on public interfaces is high. Inside Google we can use LSC's to make backward-incompatible changes, but for our open-source code we do not have that luxury. So for public interfaces, we essentially commit to never breaking backward-compatibility. This is why we must be more selective about what interfaces we publicly expose in open-source releases. I think it would be a grave mistake to sign up for this level of support for these interfaces. Especially since we aren't the authors or primary maintainers of this code. The people who change this code inside google3 are probably not thinking about open-source compatibility when they make changes. I strongly object to elevating these to public interfaces. They have never been public, and if anything we should make it more clear that they are not public.
Bazel visibility lists have never been the primary determining factor about what is private. Ideally we would clean BUILD files up to denote visibility better, but the vast majority of our users don't use Bazel anyway. The canonical way of knowing what is private is what is in the |
@haberman That makes sense that this code might have been open-sourced only for the purpose of supporting proto3 JSON and it was intended to be private. Where does that leave us with respect to this pull request, though? This PR doesn't introduce any new APIs and is arguably just a bug fix for JsonObjectWriter. |
We should file a bug on https://github.com/grpc-ecosystem/grpc-httpjson-transcoding that they are using private interfaces. We need a long-term plan for resolving this. If we have that, then I think we can accept a bugfix like this. |
@acozzette Ah. Eventually I spotted it. Every test in this file leaks memory: they all call new at the start and never delete it. I guess the CI check doesn't count pre-existing leaks. I changed the new tests to allocate on the stack, we'll see if that makes it happier. |
@asuffield I don't think that explains it because the test fixture destructor ( |
1ac511b
to
865985b
Compare
@acozzette Ah yes, you are correct (removed the pointless change). Much head-scratching later, I think I found a smoking gun:
That is a version of tcmalloc from 2015. When I run the same build using tcmalloc 2.5, there are no errors. I'm guessing that we're looking at a tcmalloc bug from the past. Please prod somebody to rebuild the kokoro docker images. |
@asuffield OK, thanks for tracking that down. But let's not worry too much about the tcmalloc problem for now because I think the more immediate issue is @haberman's concerns above about external projects using this private API. Have you tried reaching out to the grpc-httpjson-transcoding project to see if they can commit to moving off this API in the future? |
Let me go ahead and close this since it sounds like we never really reached an agreement on using these internal-only interfaces. |
This makes JsonObjectWriter fit the ObjectWriter interface, mirroring the behaviour of ProtoWriter.