Skip to content

Conversation

JonasJ-ap
Copy link
Contributor

Using recursive type check to ensure every element in the map has desired type when casting

@github-actions github-actions bot added the core label Aug 15, 2022
@jackye1995
Copy link
Contributor

thanks for the fix, I don't think we need to recursively cast, and after doing that we still need to do SuppressWarning. Given this is just a test, I think we can just add SuppressWarning to the test?

@kbendick
Copy link
Contributor

thanks for the fix, I don't think we need to recursively cast, and after doing that we still need to do SuppressWarning. Given this is just a test, I think we can just add SuppressWarning to the test?

Agreed. Since this is just test code, the potentially unsafe cast isn't really a concern here and it would be cleaner to simply add the suppression at the test level.

@JonasJ-ap JonasJ-ap changed the title Build: Resolve one unchecked type cast in TestAvroNameMapping Build: Resolve unchecked Map type cast in TestAvroNameMapping Aug 15, 2022
@JonasJ-ap
Copy link
Contributor Author

Thank you for your suggestions. The recursive type check is now replaced by two SupressWarnings

@@ -102,6 +102,7 @@ public void testMapProjections() throws IOException {
Types.NestedField.required(1, "lat", Types.FloatType.get()))))));

projected = writeAndRead(writeSchema, readSchema, record, nameMapping);
@SuppressWarnings("unchecked")
Copy link
Contributor

@jackye1995 jackye1995 Aug 15, 2022

Choose a reason for hiding this comment

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

I think we can directly place @SuppressWarnings on top of the method, so we only need 1

Copy link
Contributor

Choose a reason for hiding this comment

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

oh I see this comes from 2 methods. But even in that case I think it's always good practice to use annotation only in method declaration if possible

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for your suggestion. Since there are in total 5 unchecked warnings (2 Map types and 3 List types). I think it may be better to place one SuppressWarnings on top of the class to eliminate all the unchecked warning messages.

Copy link
Contributor

Choose a reason for hiding this comment

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

👌

Copy link
Contributor

@jackye1995 jackye1995 left a comment

Choose a reason for hiding this comment

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

thanks for the fix!

@jackye1995
Copy link
Contributor

@kbendick any additional comments?

Copy link
Contributor

@kbendick kbendick left a comment

Choose a reason for hiding this comment

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

This looks great. Thank you!!!

@jackye1995 jackye1995 merged commit 5f5c923 into apache:master Aug 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants