-
Notifications
You must be signed in to change notification settings - Fork 13
Fix generics and some formatting #59
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,5 +58,5 @@ | |
| </plugin> | ||
| </plugins> | ||
| </build> | ||
|
|
||
| </project> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -167,15 +167,15 @@ private void assertMultiCallResponse( MultiCallResponse response ) | |
| assertEquals( "org.dashbuilder-dashbuilder-parent-metadata", kojiBuildInfo.getPackageName() ); | ||
|
|
||
| // if we do not know the type, access Map directly | ||
| Map<String, Object> data1Map = (Map<String, Object>) data1; | ||
| Map<?, ?> data1Map = (Map<?, ?>) data1; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you explain why you've gone from a typed string/object to wildcards?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The goal was to correct the code and fix about 50+ compiler warnings (that show up in IDEA, but only 1 "uses unchecked or unsafe operations" shows in console without
I tried to follow best practices of Effective Java https://www.informit.com/articles/article.aspx?p=2861454&seqNum=2.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changing to I think is simply saying we have no ideas about type so there are no possible warnings to throw. This means then any .get operations aren't checked versus the original.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the It can do nothing except possibly raise a The only feature it's adding is a theoretical exception and no check. That's why I quoted Effective Java before. |
||
| assertEquals( 48475, data1Map.get( "package_id" ) ); | ||
| assertEquals( 513598, data1Map.get( "build_id" ) ); | ||
| assertEquals( "org.dashbuilder-dashbuilder-parent-metadata", data1Map.get( "package_name" ) ); | ||
|
|
||
|
|
||
| // b. verify response from listTags call | ||
|
|
||
| List<Object> data2List = (List<Object>) data2; | ||
| List<?> data2List = (List<?>) data2; | ||
| assertEquals( 4, data2List.size() ); | ||
|
|
||
| // if we know the type (KojiTagInfo) in the list, parse the element to it | ||
|
|
@@ -186,7 +186,7 @@ private void assertMultiCallResponse( MultiCallResponse response ) | |
| // if we do not know the type, access List directly | ||
| Object data2_1 = data2List.get( 0 ); | ||
| assertTrue( data2_1 instanceof Map ); | ||
| Map<String, Object> data2_1Map = (Map<String, Object>) data2_1; | ||
| Map<?, ?> data2_1Map = (Map<?, ?>) data2_1; | ||
| assertEquals( "jb-bxms-6.3-candidate", data2_1Map.get( "name" ) ); | ||
| assertEquals( 8829, data2_1Map.get( "id" ) ); | ||
| } | ||
|
|
||
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 still think it would be better to use
@SuppressWarnings( "unchecked" )here rather than the wildcard parameterised type ; this would then match your changes in e.g. Registry.java and ParseUtils.Uh oh!
There was an error while loading. Please reload this page.
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 I have a simple way to explain it. The problem is where the cast is (first line vs. second line):
Wrong way:
Right way:
When I use
@SuppressWarnings("unchecked")inRegistryandParseUtils, that was where it was safe.In other words, cast the
getnot theMap.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.
See also #48.