[jira] [Commented] (FLINK-6943) Improve exceptions within TypeExtractionUtils#getSingleAbstractMethod
[ https://issues.apache.org/jira/browse/FLINK-6943?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16062240#comment-16062240 ] ASF GitHub Bot commented on FLINK-6943: --- Github user asfgit closed the pull request at: https://github.com/apache/flink/pull/4140 > Improve exceptions within TypeExtractionUtils#getSingleAbstractMethod > - > > Key: FLINK-6943 > URL: https://issues.apache.org/jira/browse/FLINK-6943 > Project: Flink > Issue Type: Bug > Components: Core >Reporter: Dawid Wysakowicz >Assignee: Dawid Wysakowicz > > Exception message seems to be inexact. > Also if there is no SAM, sam would be null upon returning from the method. > The suggestion from a review was to change the message and add a check (for > null sam) prior to returning. > Another suggestion is to check if the given method is an interface, as only > for interface it is possible to pass lambda. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FLINK-6943) Improve exceptions within TypeExtractionUtils#getSingleAbstractMethod
[ https://issues.apache.org/jira/browse/FLINK-6943?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16059127#comment-16059127 ] ASF GitHub Bot commented on FLINK-6943: --- Github user dawidwys commented on the issue: https://github.com/apache/flink/pull/4140 Great, thanks! > Improve exceptions within TypeExtractionUtils#getSingleAbstractMethod > - > > Key: FLINK-6943 > URL: https://issues.apache.org/jira/browse/FLINK-6943 > Project: Flink > Issue Type: Bug > Components: Core >Reporter: Dawid Wysakowicz >Assignee: Dawid Wysakowicz > > Exception message seems to be inexact. > Also if there is no SAM, sam would be null upon returning from the method. > The suggestion from a review was to change the message and add a check (for > null sam) prior to returning. > Another suggestion is to check if the given method is an interface, as only > for interface it is possible to pass lambda. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FLINK-6943) Improve exceptions within TypeExtractionUtils#getSingleAbstractMethod
[ https://issues.apache.org/jira/browse/FLINK-6943?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16059017#comment-16059017 ] ASF GitHub Bot commented on FLINK-6943: --- Github user zentol commented on the issue: https://github.com/apache/flink/pull/4140 I'm preparing a big batch that I'll merge on the weekend. I have to re-use the pull request to get a proper run on travis, but during the week there's just too much going on. > Improve exceptions within TypeExtractionUtils#getSingleAbstractMethod > - > > Key: FLINK-6943 > URL: https://issues.apache.org/jira/browse/FLINK-6943 > Project: Flink > Issue Type: Bug > Components: Core >Reporter: Dawid Wysakowicz >Assignee: Dawid Wysakowicz > > Exception message seems to be inexact. > Also if there is no SAM, sam would be null upon returning from the method. > The suggestion from a review was to change the message and add a check (for > null sam) prior to returning. > Another suggestion is to check if the given method is an interface, as only > for interface it is possible to pass lambda. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FLINK-6943) Improve exceptions within TypeExtractionUtils#getSingleAbstractMethod
[ https://issues.apache.org/jira/browse/FLINK-6943?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16058994#comment-16058994 ] ASF GitHub Bot commented on FLINK-6943: --- Github user dawidwys commented on the issue: https://github.com/apache/flink/pull/4140 @zentol Are you still gonna merge it or shall I do it? > Improve exceptions within TypeExtractionUtils#getSingleAbstractMethod > - > > Key: FLINK-6943 > URL: https://issues.apache.org/jira/browse/FLINK-6943 > Project: Flink > Issue Type: Bug > Components: Core >Reporter: Dawid Wysakowicz >Assignee: Dawid Wysakowicz > > Exception message seems to be inexact. > Also if there is no SAM, sam would be null upon returning from the method. > The suggestion from a review was to change the message and add a check (for > null sam) prior to returning. > Another suggestion is to check if the given method is an interface, as only > for interface it is possible to pass lambda. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FLINK-6943) Improve exceptions within TypeExtractionUtils#getSingleAbstractMethod
[ https://issues.apache.org/jira/browse/FLINK-6943?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16055796#comment-16055796 ] ASF GitHub Bot commented on FLINK-6943: --- Github user zentol commented on the issue: https://github.com/apache/flink/pull/4140 merging. > Improve exceptions within TypeExtractionUtils#getSingleAbstractMethod > - > > Key: FLINK-6943 > URL: https://issues.apache.org/jira/browse/FLINK-6943 > Project: Flink > Issue Type: Bug > Components: Core >Reporter: Dawid Wysakowicz >Assignee: Dawid Wysakowicz > > Exception message seems to be inexact. > Also if there is no SAM, sam would be null upon returning from the method. > The suggestion from a review was to change the message and add a check (for > null sam) prior to returning. > Another suggestion is to check if the given method is an interface, as only > for interface it is possible to pass lambda. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FLINK-6943) Improve exceptions within TypeExtractionUtils#getSingleAbstractMethod
[ https://issues.apache.org/jira/browse/FLINK-6943?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16055762#comment-16055762 ] ASF GitHub Bot commented on FLINK-6943: --- Github user tedyu commented on the issue: https://github.com/apache/flink/pull/4140 lgtm > Improve exceptions within TypeExtractionUtils#getSingleAbstractMethod > - > > Key: FLINK-6943 > URL: https://issues.apache.org/jira/browse/FLINK-6943 > Project: Flink > Issue Type: Bug > Components: Core >Reporter: Dawid Wysakowicz >Assignee: Dawid Wysakowicz > > Exception message seems to be inexact. > Also if there is no SAM, sam would be null upon returning from the method. > The suggestion from a review was to change the message and add a check (for > null sam) prior to returning. > Another suggestion is to check if the given method is an interface, as only > for interface it is possible to pass lambda. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FLINK-6943) Improve exceptions within TypeExtractionUtils#getSingleAbstractMethod
[ https://issues.apache.org/jira/browse/FLINK-6943?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16055730#comment-16055730 ] ASF GitHub Bot commented on FLINK-6943: --- Github user zentol commented on the issue: https://github.com/apache/flink/pull/4140 +1. > Improve exceptions within TypeExtractionUtils#getSingleAbstractMethod > - > > Key: FLINK-6943 > URL: https://issues.apache.org/jira/browse/FLINK-6943 > Project: Flink > Issue Type: Bug > Components: Core >Reporter: Dawid Wysakowicz >Assignee: Dawid Wysakowicz > > Exception message seems to be inexact. > Also if there is no SAM, sam would be null upon returning from the method. > The suggestion from a review was to change the message and add a check (for > null sam) prior to returning. > Another suggestion is to check if the given method is an interface, as only > for interface it is possible to pass lambda. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FLINK-6943) Improve exceptions within TypeExtractionUtils#getSingleAbstractMethod
[ https://issues.apache.org/jira/browse/FLINK-6943?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16054025#comment-16054025 ] ASF GitHub Bot commented on FLINK-6943: --- Github user zentol commented on a diff in the pull request: https://github.com/apache/flink/pull/4140#discussion_r122711527 --- Diff: flink-core/src/main/java/org/apache/flink/api/java/typeutils/TypeExtractionUtils.java --- @@ -215,22 +215,33 @@ public static Type extractTypeArgument(Type t, int index) throws InvalidTypesExc * Extracts a Single Abstract Method (SAM) as defined in Java Specification (4.3.2. The Class Object, * 9.8 Functional Interfaces, 9.4.3 Interface Method Body) from given class. * -* @param baseClass -* @throws InvalidTypesException if the given class does not implement -* @return +* @param baseClass a class that is a FunctionalInterface to retrieve a SAM from +* @throws InvalidTypesException if the given class does not implement FunctionalInterface +* @return single abstract method of the given class */ public static Method getSingleAbstractMethod(Class baseClass) { + + if (!baseClass.isInterface()) { + throw new InvalidTypesException("FunctionalInterface must be an interface"); --- End diff -- My main concern is consistency with other exception messages; they all include the base class. I would suggest "... is not a FunctionalInterface."; i don't think we need the "which implies..." bit. > Improve exceptions within TypeExtractionUtils#getSingleAbstractMethod > - > > Key: FLINK-6943 > URL: https://issues.apache.org/jira/browse/FLINK-6943 > Project: Flink > Issue Type: Bug > Components: Core >Reporter: Dawid Wysakowicz >Assignee: Dawid Wysakowicz > > Exception message seems to be inexact. > Also if there is no SAM, sam would be null upon returning from the method. > The suggestion from a review was to change the message and add a check (for > null sam) prior to returning. > Another suggestion is to check if the given method is an interface, as only > for interface it is possible to pass lambda. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FLINK-6943) Improve exceptions within TypeExtractionUtils#getSingleAbstractMethod
[ https://issues.apache.org/jira/browse/FLINK-6943?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16054005#comment-16054005 ] ASF GitHub Bot commented on FLINK-6943: --- Github user dawidwys commented on a diff in the pull request: https://github.com/apache/flink/pull/4140#discussion_r122708789 --- Diff: flink-core/src/main/java/org/apache/flink/api/java/typeutils/TypeExtractionUtils.java --- @@ -215,22 +215,33 @@ public static Type extractTypeArgument(Type t, int index) throws InvalidTypesExc * Extracts a Single Abstract Method (SAM) as defined in Java Specification (4.3.2. The Class Object, * 9.8 Functional Interfaces, 9.4.3 Interface Method Body) from given class. * -* @param baseClass -* @throws InvalidTypesException if the given class does not implement -* @return +* @param baseClass a class that is a FunctionalInterface to retrieve a SAM from +* @throws InvalidTypesException if the given class does not implement FunctionalInterface +* @return single abstract method of the given class */ public static Method getSingleAbstractMethod(Class baseClass) { + + if (!baseClass.isInterface()) { + throw new InvalidTypesException("FunctionalInterface must be an interface"); --- End diff -- Yes and no, I would say. Given class must be a FunctionalInterface which implies it has to be an interface. If you feel. How about such a message: "Given class must be a FunctionalInterface which implies it has to be an interface."? > Improve exceptions within TypeExtractionUtils#getSingleAbstractMethod > - > > Key: FLINK-6943 > URL: https://issues.apache.org/jira/browse/FLINK-6943 > Project: Flink > Issue Type: Bug > Components: Core >Reporter: Dawid Wysakowicz >Assignee: Dawid Wysakowicz > > Exception message seems to be inexact. > Also if there is no SAM, sam would be null upon returning from the method. > The suggestion from a review was to change the message and add a check (for > null sam) prior to returning. > Another suggestion is to check if the given method is an interface, as only > for interface it is possible to pass lambda. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FLINK-6943) Improve exceptions within TypeExtractionUtils#getSingleAbstractMethod
[ https://issues.apache.org/jira/browse/FLINK-6943?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16053993#comment-16053993 ] ASF GitHub Bot commented on FLINK-6943: --- Github user zentol commented on a diff in the pull request: https://github.com/apache/flink/pull/4140#discussion_r122707710 --- Diff: flink-core/src/main/java/org/apache/flink/api/java/typeutils/TypeExtractionUtils.java --- @@ -215,22 +215,33 @@ public static Type extractTypeArgument(Type t, int index) throws InvalidTypesExc * Extracts a Single Abstract Method (SAM) as defined in Java Specification (4.3.2. The Class Object, * 9.8 Functional Interfaces, 9.4.3 Interface Method Body) from given class. * -* @param baseClass -* @throws InvalidTypesException if the given class does not implement -* @return +* @param baseClass a class that is a FunctionalInterface to retrieve a SAM from +* @throws InvalidTypesException if the given class does not implement FunctionalInterface +* @return single abstract method of the given class */ public static Method getSingleAbstractMethod(Class baseClass) { + + if (!baseClass.isInterface()) { + throw new InvalidTypesException("FunctionalInterface must be an interface"); --- End diff -- Shouldn't this say "Given class ... must be an interface."? > Improve exceptions within TypeExtractionUtils#getSingleAbstractMethod > - > > Key: FLINK-6943 > URL: https://issues.apache.org/jira/browse/FLINK-6943 > Project: Flink > Issue Type: Bug > Components: Core >Reporter: Dawid Wysakowicz >Assignee: Dawid Wysakowicz > > Exception message seems to be inexact. > Also if there is no SAM, sam would be null upon returning from the method. > The suggestion from a review was to change the message and add a check (for > null sam) prior to returning. > Another suggestion is to check if the given method is an interface, as only > for interface it is possible to pass lambda. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FLINK-6943) Improve exceptions within TypeExtractionUtils#getSingleAbstractMethod
[ https://issues.apache.org/jira/browse/FLINK-6943?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16053674#comment-16053674 ] ASF GitHub Bot commented on FLINK-6943: --- GitHub user dawidwys opened a pull request: https://github.com/apache/flink/pull/4140 [FLINK-6943] Improve exceptions within TypeExtractionUtils#getSingleA… …bstractMethod Thanks for contributing to Apache Flink. Before you open your pull request, please take the following check list into consideration. If your changes take all of the items into account, feel free to open your pull request. For more information and/or questions please refer to the [How To Contribute guide](http://flink.apache.org/how-to-contribute.html). In addition to going through the list, please provide a meaningful description of your changes. - [ ] General - The pull request references the related JIRA issue ("[FLINK-XXX] Jira title text") - The pull request addresses only one issue - Each commit in the PR has a meaningful commit message (including the JIRA id) - [ ] Documentation - Documentation has been added for new functionality - Old documentation affected by the pull request has been updated - JavaDoc for public methods has been added - [ ] Tests & Build - Functionality added by the pull request is covered by tests - `mvn clean verify` has been executed successfully locally or a Travis build has passed You can merge this pull request into a Git repository by running: $ git pull https://github.com/dawidwys/flink flink6943 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/flink/pull/4140.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #4140 commit 316afb3085486186a098b4aa9607a0b269a5312b Author: Dawid WysakowiczDate: 2017-06-19T07:38:25Z [FLINK-6943] Improve exceptions within TypeExtractionUtils#getSingleAbstractMethod > Improve exceptions within TypeExtractionUtils#getSingleAbstractMethod > - > > Key: FLINK-6943 > URL: https://issues.apache.org/jira/browse/FLINK-6943 > Project: Flink > Issue Type: Bug > Components: Core >Reporter: Dawid Wysakowicz >Assignee: Dawid Wysakowicz > > Exception message seems to be inexact. > Also if there is no SAM, sam would be null upon returning from the method. > The suggestion from a review was to change the message and add a check (for > null sam) prior to returning. > Another suggestion is to check if the given method is an interface, as only > for interface it is possible to pass lambda. -- This message was sent by Atlassian JIRA (v6.4.14#64029)