Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

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

Merged
merged 1 commit into from
Feb 12, 2021

Conversation

dapengzhang0
Copy link
Contributor

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

@vam-google

@dapengzhang0 dapengzhang0 requested review from a team as code owners February 10, 2021 22:48
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Feb 10, 2021
@codecov
Copy link

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

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

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

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

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

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

Choose a reason for hiding this comment

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

LGTM, but please address @elharo comments first

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

InstantiatingGrpcChannelProvider provider =
Copy link
Contributor

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
@dapengzhang0 dapengzhang0 deleted the fix-builder-bug branch February 12, 2021 19:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants