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

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.trino.plugin.base;

import com.google.errorprone.annotations.Keep;

/**
* An annotation to put on record parameters as a workaround to
* <a href="https://github.com/google/error-prone/issues/2713">error-prone's 2713 issue</a>.
*/
@Keep
public @interface RecordParameter {}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import io.airlift.jmx.CacheStatsMBean;
import io.airlift.units.Duration;
import io.trino.collect.cache.EvictableCacheBuilder;
import io.trino.plugin.base.RecordParameter;
import io.trino.plugin.base.session.SessionPropertiesProvider;
import io.trino.plugin.jdbc.IdentityCacheMapping.IdentityCacheKey;
import io.trino.spi.TrinoException;
Expand Down Expand Up @@ -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)
ebyhr marked this conversation as resolved.
Show resolved Hide resolved
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

{
@SuppressWarnings("UnusedVariable") // TODO: Remove once https://github.com/google/error-prone/issues/2713 is fixed
private ColumnsCacheKey
{
requireNonNull(identity, "identity is null");
Expand Down