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: Preconditions only supports %s format #1153

Merged
merged 1 commit into from Jul 21, 2020

Conversation

noahdietz
Copy link
Contributor

@noahdietz noahdietz commented Jul 21, 2020

Preconditions only support use of the %s format specifier (docs) and gax-java had a %d format specifier. This switches it to %s.

The following error showed up in bazel builds of java_gapic_library targets on HEAD of googleapis:

external/com_google_api_gax_java/gax-grpc/src/main/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProvider.java:539: error: [PreconditionsInvalidPlaceholder] Preconditions only accepts the %s placeholder in error message strings
          poolSize <= MAX_POOL_SIZE, "Pool size must be less than %d", MAX_POOL_SIZE);
                                     ^
    (see https://errorprone.info/bugpattern/PreconditionsInvalidPlaceholder)
  Did you mean 'poolSize <= MAX_POOL_SIZE, "Pool size must be less than %s", MAX_POOL_SIZE);'?

I'm not sure what changed, maybe the dependency version brought was updated transiently to the later versions that throw an exception on format specifier support in Preconditions. Regardless, this is an easy fix.

@noahdietz noahdietz requested review from miraleung and vam-google Jul 21, 2020
@google-cla google-cla bot added the cla: yes label Jul 21, 2020
@codecov
Copy link

@codecov codecov bot commented Jul 21, 2020

Codecov Report

Merging #1153 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #1153   +/-   ##
=========================================
  Coverage     78.65%   78.65%           
  Complexity     1170     1170           
=========================================
  Files           204      204           
  Lines          5195     5195           
  Branches        417      417           
=========================================
  Hits           4086     4086           
  Misses          935      935           
  Partials        174      174           
Impacted Files Coverage Δ Complexity Δ
...api/gax/grpc/InstantiatingGrpcChannelProvider.java 77.83% <ø> (ø) 33.00 <0.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 9645752...892414e. Read the comment docs.

Copy link
Contributor

@miraleung miraleung left a comment

Alternatively, String.format("Pool size ... %d", MAX_POOL_SIZE)

@noahdietz noahdietz merged commit 8145311 into googleapis:master Jul 21, 2020
8 checks passed
@noahdietz noahdietz deleted the fix-preconidition branch Jul 21, 2020
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

2 participants