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

Clean up compiler warnings #130

Closed
5 of 6 tasks
dbwiddis opened this issue Sep 8, 2022 · 4 comments
Closed
5 of 6 tasks

Clean up compiler warnings #130

dbwiddis opened this issue Sep 8, 2022 · 4 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@dbwiddis
Copy link
Member

dbwiddis commented Sep 8, 2022

Some code on main is producing compiler warnings and should be cleaned up so I don't see so many ⚠️s in my IDE.

  • TransportActions.java Class on line 29 needs type arguments. (Class<? extends TransportAction<? extends ActionRequest, ? extends ActionResponse>>>). This will need a simultaneous change to OpenSearch project feature/extensions branch RegisterTransportActionsRequest constructor (and associated instance variable).
  • TransportAction.java HashMap on line 38 needs a diamond operator (<>)
  • NamedWriteableRegistryApi.java lines 84 and 107 need generic types for the Class (probably <? extends NamedWritable>). This will need a simultaneous change to OpenSearch project feature/extensions branch NamedWriteable RegistryParseRequest to change the type of categoryClass to add the same generics.
  • SDKClient.java has an unused logger. Either log something or remove it.
  • TestNamedWriteable.java has an unused inner class constructor Example(String message). I suspect this means there's missing tests somewhere.
  • Unused field extensionsRunner in NettyTransport (probably the result of a merge conflict resolution)
@dbwiddis
Copy link
Member Author

FYI, just noticed this in gradle check logs:

Note: /home/runner/work/opensearch-sdk-java/opensearch-sdk-java/src/main/java/org/opensearch/sdk/ExtensionNamedWriteableRegistry.java uses unchecked or unsafe operations.

I believe that fixing this issue will resolve this warning.

@mloufra
Copy link
Contributor

mloufra commented Oct 13, 2022

  • TransportActions.java Class on line 29 needs type arguments. (Class<? extends TransportAction<? extends ActionRequest, ? extends ActionResponse>>>). This will need a simultaneous change to OpenSearch project feature/extensions branch RegisterTransportActionsRequest constructor (and associated instance variable).

Can we use @SuppressWarnings(“rawtypes”) to ignore compiler warning for clean up purpose?

@owaiskazi19
Copy link
Member

Can we use @SuppressWarnings(“rawtypes”) to ignore compiler warning for clean up purpose?

Hey @mloufra! SuppressWarnings is used to ignore the warnings. We don't have to ignore them but to resolve them. We need to add a type argument by making the change in OpenSearch repo's feature/extensions branch RegisterTransportActionsRequest constructor.

@dbwiddis
Copy link
Member Author

Can we use @SuppressWarnings(“rawtypes”) to ignore compiler warning for clean up purpose?

As a follow-up, there are cases in Writeable objects using the StreamInput constructor where we are using Class.forName() to generate the class and don't have the type information as part of that (writeable String). In those cases, cast the returned Class to the appropriate type, and it is acceptable if you have double- and triple-checked that the signature matches the class in writeTo(), to add the @SuppressWarnings("unchecked") annotation for this unchecked cast.

@mloufra mloufra closed this as completed Oct 27, 2022
kokibas pushed a commit to kokibas/opensearch-sdk-java that referenced this issue Mar 17, 2023
Minor changes for warnings removal.

NamedWriteableRegistryAPI
  remove unused local variables
  remove unused imports

SDKClient
  remove unused private attribute
  remove unsed imports

TransportActions
  add missing diamond operators

TestNamedWriteableRegistryAPI
  remove unused constructor

There are still missing generic declaration on Class<> attributes and
variables, which cannot be fixed only through sdk project, as they are
used as method parameters from classes that do not belong to sdk project
and would require changes on these classes as well.

fix opensearch-project#130

Signed-off-by: Lucas Faria e Souza Vilela <[email protected]>

Signed-off-by: Lucas Faria e Souza Vilela <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants