hadoop-yarn-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Templeton (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (YARN-4457) Cleanup unchecked types for EventHandler
Date Thu, 19 May 2016 00:28:12 GMT

    [ https://issues.apache.org/jira/browse/YARN-4457?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15290164#comment-15290164

Daniel Templeton commented on YARN-4457:

Oh, [~kasha], if only it were that simple.  A {{Dispatcher}} is intended to handle a variety
of event types.  The {{register()}} method lets classes register a specific handler for a
specific event type.  It is really untyped with respect to events.  The confusion comes from
the {{getEventHandler()}} convenience method, which returns a generic event handler, not one
of the ones that was registered.

In theory we could have the method return an {{EventHandler<? extends Event>}}, which
would be more specific.  It doesn't actually change anything, however, as the {{EventHandler.handle()}}
method (it's only method) would still accept a parameter of type {{Event}}, and it's bad practice
to have a wildcarded type as the return type.  Wildcards are icky, and forcing callers to
deal with them by putting them in the return type is bad form.

> Cleanup unchecked types for EventHandler
> ----------------------------------------
>                 Key: YARN-4457
>                 URL: https://issues.apache.org/jira/browse/YARN-4457
>             Project: Hadoop YARN
>          Issue Type: Improvement
>    Affects Versions: 2.7.1
>            Reporter: Daniel Templeton
>            Assignee: Daniel Templeton
>         Attachments: YARN-4457.001.patch, YARN-4457.002.patch, YARN-4457.003.patch, YARN-4457.004.patch,
> The EventHandler class is often used in an untyped context resulting in a bunch of warnings
about unchecked usage.  The culprit is the {{Dispatcher.getHandler()}} method.  Fixing the
typing on the method to return {{EventHandler<Event>}} instead of {{EventHandler}} clears
up the errors and doesn't not introduce any incompatible changes.  In the case that some code
> {code}
> EventHandler h = dispatcher.getHandler();
> {code}
> it will still work and will issue a compiler warning about raw types.  There are, however,
no instances of this issue in the current source base.

This message was sent by Atlassian JIRA

To unsubscribe, e-mail: yarn-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: yarn-issues-help@hadoop.apache.org

View raw message