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

fix: InstantiatingGrpcChannelProvider.toBuilder() should carry over all config data #1298

Merged
merged 1 commit into from Feb 12, 2021

Conversation

dapengzhang0
Copy link
Contributor

@dapengzhang0 dapengzhang0 commented Feb 10, 2021

#1235 introduced a bug that InstantiatingGrpcChannelProvider.toBuilder() is missing the config data.

@vam-google

@dapengzhang0 dapengzhang0 requested review from as code owners Feb 10, 2021
@google-cla google-cla bot added the cla: yes label Feb 10, 2021
@codecov
Copy link

@codecov codecov bot commented Feb 10, 2021

Codecov Report

Merging #1298 (a68f689) into master (721617b) will increase coverage by 0.17%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #1298      +/-   ##
============================================
+ Coverage     79.34%   79.51%   +0.17%     
- Complexity     1235     1236       +1     
============================================
  Files           209      209              
  Lines          5398     5399       +1     
  Branches        454      454              
============================================
+ Hits           4283     4293      +10     
+ Misses          936      928       -8     
+ Partials        179      178       -1     
Impacted Files Coverage Δ Complexity Δ
...api/gax/grpc/InstantiatingGrpcChannelProvider.java 77.46% <100.00%> (+3.40%) 35.00 <0.00> (ø)
.../java/com/google/api/gax/batching/BatcherImpl.java 98.06% <0.00%> (+1.29%) 17.00% <0.00%> (+1.00%)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 721617b...a68f689. Read the comment docs.


InstantiatingGrpcChannelProvider.Builder builder = provider.toBuilder();

assertThat(builder.getEndpoint()).isEqualTo("fake.endpoint:443");
Copy link
Contributor

@elharo elharo Feb 11, 2021

Choose a reason for hiding this comment

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

gratuitous use of Truth. assertEquals is fully adequate here

Copy link
Contributor Author

@dapengzhang0 dapengzhang0 Feb 11, 2021

Choose a reason for hiding this comment

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

Did you mean org.junit.Assert.assertEquals() as I did't find Truth. assertEquals()? For org.junit.Assert.assertEquals() we tend to put expected value and actual value in wrong order and its error message is not as detailed as Truth. assertEquals().

};
Map<String, ?> directPathServiceConfig = ImmutableMap.of("loadbalancingConfig", "grpclb");

InstantiatingGrpcChannelProvider provider =
Copy link
Contributor

@elharo elharo Feb 11, 2021

Choose a reason for hiding this comment

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

does this class have a good equals method? that could make for a more robust test.

Copy link
Contributor

@vam-google vam-google Feb 11, 2021

Choose a reason for hiding this comment

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

It does not (resolves to default Object#equals())

Copy link
Contributor Author

@dapengzhang0 dapengzhang0 Feb 11, 2021

Choose a reason for hiding this comment

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

InstantiatingGrpcChannelProvider has complex logic such as relation between PoolSize and ProcessorCount and ChannelsPerCpu, and attributes depending on system properties and env. It might not make much sense to simply implement equals() by comparing its fields, just for testing purpose.

Copy link
Contributor

@vam-google vam-google left a comment

LGTM, but please address @elharo comments first

};
Map<String, ?> directPathServiceConfig = ImmutableMap.of("loadbalancingConfig", "grpclb");

InstantiatingGrpcChannelProvider provider =
Copy link
Contributor

@vam-google vam-google Feb 11, 2021

Choose a reason for hiding this comment

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

It does not (resolves to default Object#equals())

@vam-google vam-google merged commit 0bc5dc5 into googleapis:master Feb 12, 2021
9 checks passed
@dapengzhang0 dapengzhang0 deleted the fix-builder-bug branch Feb 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants