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

Workaround error-prone record problem without warning suppression #16657

Conversation

findepi
Copy link
Member

@findepi findepi commented Mar 21, 2023

Warning suppression is not ideal as it may lead to suppression of more then originally desired. Work around
google/error-prone#2713 using error-prone's annotation-based suppression mechanism.

Note: using @Keep directly is not effective. Only @Keep-annotated annotation seems to work.

Note 2: using this annotation isn't usually required, as parameter validation in compact constructor usually makes error-prone happy and avoids aforementioned issue. Use it only when needed.

Warning suppression is not ideal as it may lead to suppression of more
then originally desired. Work around
google/error-prone#2713 using error-prone's
annotation-based suppression mechanism.

Note: using `@Keep` directly is not effective. Only `@Keep`-annotated
annotation seems to work.

Note 2: using this annotation isn't usually required, as parameter
validation in compact constructor usually makes error-prone happy and
avoids aforementioned issue. Use it only when needed.
@findepi findepi added the no-release-notes This pull request does not require release notes entry label Mar 21, 2023
@cla-bot cla-bot bot added the cla-signed label Mar 21, 2023
@findepi findepi force-pushed the findepi/workaround-error-prone-record-problem-without-warning-suppression-745abb branch from 333dbc3 to 67adea7 Compare March 21, 2023 21:36
@findepi
Copy link
Member Author

findepi commented Mar 22, 2023

CI #16653

Copy link
Member

@martint martint left a comment

Choose a reason for hiding this comment

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

Let’s not add new abstractions to work around a bug in errorprone. If we’re having issues with this, I’d rather disable this check until the bug is fixed and then re-enable and fix any new call sites that may sneak in in the meantime.

@findepi
Copy link
Member Author

findepi commented Mar 22, 2023

The check is useful in general, it just doesn't work for records. So no, we should not disable it.
We can choose whether we are able to apply temporary workarounds (and just move forward), or not apply temporary workarounds, and just keep creating non-record classes every time we hit the limitation (which would be more cumbersome to convert to records later). I understand @martint you prefer the latter, non-record classes.

@findepi findepi requested a review from martint March 22, 2023 16:23
@findepi findepi dismissed martint’s stale review March 22, 2023 21:08

the PR does not add new abstractions

@findepi
Copy link
Member Author

findepi commented Mar 22, 2023

@martint PTAL

@findepi findepi requested review from martint and removed request for martint March 23, 2023 08:12
@martint
Copy link
Member

martint commented Mar 23, 2023

That’s preferable until it gets fixed. However, is there a timeframe for that? The issue seems to be open since middle of 2021. If there’s no end in sight, we can’t be held hostage to a buggy third party library.

@@ -658,9 +659,8 @@ private static <T, V> void invalidateCache(Cache<T, V> cache, Predicate<T> filte
cache.invalidateAll(cacheKeys);
}

private record ColumnsCacheKey(IdentityCacheKey identity, Map<String, Object> sessionProperties, SchemaTableName table)
private record ColumnsCacheKey(@RecordParameter IdentityCacheKey identity, @RecordParameter Map<String, Object> sessionProperties, @RecordParameter SchemaTableName table)
Copy link
Member

Choose a reason for hiding this comment

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

The annotation is redundant information that doesn’t add any information and pollutes the codebase. It’s not clear why or when it should be used. See my other comments earlier

Copy link
Member Author

Choose a reason for hiding this comment

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

Would different annotation name help?

what do you suggest instead? not use records?
remove a checker that's generally helpful for code reviews and is net positive overall?

Copy link
Member

Choose a reason for hiding this comment

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

Ideally, get that error-prone bug fixed. Until that happens, avoid records in the places it causes trouble (clearly it’s not everywhere, since we’re already using records without problems in many cases). If the fix is not getting in in a reasonable amount of time and no one is willing to help push for it, we’ll have to disable the check eventually.

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 agree it would be best to have the error-prone bug fixed.
i won't spend more time on this. Adding an annotation to smooth out our code and our review process is an improvement. Fixing error-prone is also an improvement, but beyond my time budget, unfortunately.
BTW, being not less constructive, i won't agree to disable the check

@findepi findepi closed this Mar 23, 2023
@findepi findepi deleted the findepi/workaround-error-prone-record-problem-without-warning-suppression-745abb branch March 23, 2023 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed no-release-notes This pull request does not require release notes entry
Development

Successfully merging this pull request may close these issues.

None yet

5 participants