Skip to content
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

api,netty: fix MethodDescriptor and InternalKnownTransport for netty-shaded #6774

Merged
merged 2 commits into from
Feb 27, 2020

Conversation

dapengzhang0
Copy link
Member

Continue to use enum InternalKnownTransport and extend it for ABI backward compatibility (hopefully).

new InternalMethodDescriptor(InternalKnownTransport.NETTY);
new InternalMethodDescriptor(
NettyClientTransport.class.getName().contains("grpc.netty.shaded")
? InternalKnownTransport.NETTY_SHADED : InternalKnownTransport.NETTY);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if it's possible that the compiler can optimize this contains()?: expression and replace it with InternalKnownTransport.NETTY directly before shadow plugin does its job. My local interop test did not show it happened.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it won't be able to rework this string. You could also just do "shaded" as another option. But all those variations should be fine.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just "shaded" will produce false positive if grpc as a whole is shaded by the application.

@dapengzhang0
Copy link
Member Author

Resolves #6765

@@ -51,7 +51,8 @@

// Must be set to InternalKnownTransport.values().length
// Not referenced to break the dependency.
private final AtomicReferenceArray<Object> rawMethodNames = new AtomicReferenceArray<>(1);
private final AtomicReferenceArray<Object> rawMethodNames =
new AtomicReferenceArray<>(InternalKnownTransport.values().length);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will break Bazel; use a literal 2.

The comment alludes to why this was done, but even if you thought that no longer applied the comment should have been removed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

InternalKnownTransport is part of grpc-api so Bazel seems not impacted. It breaks blaze though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noticed there were already comments on this field

// Must be set to InternalKnownTransport.values().length
// Not referenced to break the dependency.
private final AtomicReferenceArray<Object> rawMethodNames =

new InternalMethodDescriptor(InternalKnownTransport.NETTY);
new InternalMethodDescriptor(
NettyClientTransport.class.getName().contains("grpc.netty.shaded")
? InternalKnownTransport.NETTY_SHADED : InternalKnownTransport.NETTY);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it won't be able to rework this string. You could also just do "shaded" as another option. But all those variations should be fine.

@ejona86 ejona86 added the TODO:backport PR needs to be backported. Removed after backport complete label Feb 27, 2020
@dapengzhang0 dapengzhang0 merged commit 5677a0b into grpc:master Feb 27, 2020
@dapengzhang0 dapengzhang0 deleted the fix-method-descriptor-shaded branch February 27, 2020 20:54
@ejona86 ejona86 removed the TODO:backport PR needs to be backported. Removed after backport complete label Mar 9, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants