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

build: use errorprone's GuardedBy rather than javax's #2061

Merged
merged 3 commits into from
Oct 4, 2023

Conversation

suztomo
Copy link
Member

@suztomo suztomo commented Oct 3, 2023

Towards #1938 . This pull request replaces javax.annotation.concurrent.GuardedBy with errorprone's annotation. The official documentation https://github.com/google/error-prone/blob/master/docs/bugpattern/GuardedBy.md uses com.google.errorprone.annotations.concurrent.GuardedBy.

To reviewers, if you wonder whether the GuardedBy annotation has any effect, see the Bazel build caught a bug I intentionally introduced in #2060.

@suztomo suztomo requested a review from a team as a code owner October 3, 2023 20:13
@product-auto-label product-auto-label bot added the size: xs Pull request size is extra small. label Oct 3, 2023
@suztomo suztomo requested a review from blakeli0 October 3, 2023 20:16
@blakeli0
Copy link
Collaborator

blakeli0 commented Oct 3, 2023

I guess this is one of the effort to replace all Javax annotation usages?

@suztomo
Copy link
Member Author

suztomo commented Oct 3, 2023

external/com_google_api_gax_java/gax/src/main/java/com/google/api/gax/rpc/ServerStreamingAttemptCallable.java:110: error: could not resolve GuardedBy

@suztomo
Copy link
Member Author

suztomo commented Oct 3, 2023

I guess this is one of the effort to replace all Javax annotation usages?

@blakeli0 Yes, this change is towards the goal. However, we use tools that still use the javax annotations (#1938 (comment)) and, fortunately, there's no known problems in using javax annotations so far. I don't think we will replace the javax annotations completely anytime soon.

@sonarcloud
Copy link

sonarcloud bot commented Oct 3, 2023

[gapic-generator-java-root] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@sonarcloud
Copy link

sonarcloud bot commented Oct 3, 2023

[java_showcase_integration_tests] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@sonarcloud
Copy link

sonarcloud bot commented Oct 3, 2023

[java_showcase_unit_tests] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@blakeli0
Copy link
Collaborator

blakeli0 commented Oct 3, 2023

I don't think we will replace the javax annotations completely anytime soon.

If this is the case, do we want to pursue more replacements of javax annotations at this moment?

@@ -35,6 +35,7 @@
import com.google.api.gax.httpjson.HttpRequestRunnable.RunnableResult;
import com.google.api.gax.rpc.StatusCode;
import com.google.common.base.Preconditions;
import com.google.errorprone.annotations.concurrent.GuardedBy;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a documentation that GuardedBy from errorprone and javax have the exact same bahavior?

Copy link
Member Author

Choose a reason for hiding this comment

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

https://errorprone.info/bugpattern/GuardedBy

Note: there are a couple more annotations called @GuardedBy, including javax.annotation.concurrent.GuardedBy and org.checkerframework.checker.lock.qual.GuardedBy. The check recognizes those versions of the annotation, but we recommend using com.google.errorprone.annotations.concurrent.GuardedBy.

So errorprone treats the GuardedBy annotations from errorprone and javax in the same manner.

@suztomo
Copy link
Member Author

suztomo commented Oct 4, 2023

do we want to pursue more replacements of javax annotations at this moment?

@blakeli0 Not for this pull request. This GuardedBy is the first one I can easily move. We may find replacements for other annotations listed in #1938. We'll have another pull request at that time.

@blakeli0
Copy link
Collaborator

blakeli0 commented Oct 4, 2023

do we want to pursue more replacements of javax annotations at this moment?

@blakeli0 Not for this pull request. This GuardedBy is the first one I can easily move. We may find replacements for other annotations listed in #1938. We'll have another pull request at that time.

Thanks, this PR LGTM. What I'm concerning is that should we keep the issue #1938 in our ready-to-fix backlog. We should move it out if we think it will not be fixed anytime soon.

@suztomo suztomo merged commit 39f7317 into main Oct 4, 2023
36 checks passed
@suztomo suztomo deleted the errorprone_GuardedBy branch October 4, 2023 13:10
@suztomo
Copy link
Member Author

suztomo commented Oct 4, 2023

Let's remove #1938 from the ready-to-fix backlog.

@suztomo
Copy link
Member Author

suztomo commented Oct 4, 2023

I'll create child issues for each annotations.

@suztomo
Copy link
Member Author

suztomo commented Oct 4, 2023

#2063

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: xs Pull request size is extra small.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants