-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Build: Resolve unchecked Map type cast in TestAvroNameMapping #5541
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
Conversation
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 |
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. |
…he unchecked Map casting
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") |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌
There was a problem hiding this 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!
@kbendick any additional comments? |
There was a problem hiding this 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!!!
Using recursive type check to ensure every element in the map has desired type when casting