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

Disallow mutable array use as a constant #10604

Merged
merged 2 commits into from
Jan 15, 2022

Conversation

findepi
Copy link
Member

@findepi findepi commented Jan 14, 2022

Arrays are mutable, so are not suitable for public static fields.

@cla-bot cla-bot bot added the cla-signed label Jan 14, 2022
@findepi findepi force-pushed the findepi/immutable-array branch 2 times, most recently from 0a3e98b to 6524fbe Compare January 14, 2022 10:31
import java.util.List;
import java.util.stream.Collectors;

public class TextRcFileEncoding
implements RcFileEncoding
{
public static final byte[] DEFAULT_SEPARATORS = new byte[] {
private static final byte[] DEFAULT_SEPARATORS = new byte[] {
Copy link
Member

Choose a reason for hiding this comment

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

Should we consider using ImmutableList instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

Generally yes, but the byte[] is used in other places, so that would be a bigger change, and maybe not warranted in this particular case

@findepi
Copy link
Member Author

findepi commented Jan 14, 2022

Build is green. Will resolve conflict and merge.

Arrays are mutable, so are not suitable for public static fields.
The checks disabled are WARN level by default. Disable them altogether,
for the benefit of anyone who cares to look at the Error Prone output,
for whatever reason.
@findepi findepi force-pushed the findepi/immutable-array branch from 6524fbe to 9892e61 Compare January 15, 2022 09:26
@findepi findepi merged commit 2190ab7 into trinodb:master Jan 15, 2022
@findepi findepi deleted the findepi/immutable-array branch January 15, 2022 09:26
@github-actions github-actions bot added this to the 369 milestone Jan 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

4 participants