[ 
https://issues.apache.org/jira/browse/FLINK-4883?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15607635#comment-15607635
 ] 

Renkai Ge commented on FLINK-4883:
----------------------------------

I found a way to distinguish normal scala instances and objects, that is the 
class name of scala objects would be suffixed by a `$` symbol.Though Java users 
can name a class suffixed by a `$`, too, it is discouraged and seldom people 
will do this.

I think we can scan every function in the generated execution plan before it 
send to the cluster, if any function have a class name suffixed by `$`, we can 
throw exception and tell them not to use scala object to extend functions.

The risk is, it seems distinguish object and normal class by class name is a 
hacking but not scala standard, furture versions of scala may have a different 
way to implement object then this method lost effectiveness.

What's your opinion? [~srichter]

> Prevent UDFs implementations through Scala singleton objects
> ------------------------------------------------------------
>
>                 Key: FLINK-4883
>                 URL: https://issues.apache.org/jira/browse/FLINK-4883
>             Project: Flink
>          Issue Type: Bug
>            Reporter: Stefan Richter
>            Assignee: Renkai Ge
>
> Currently, user can create and use UDFs in Scala like this:
> {code}
> object FlatMapper extends RichCoFlatMapFunction[Long, String, (Long, String)] 
> {
> ...
> }
> {code}
> However, this leads to problems as the UDF is now a singleton that Flink 
> could use across several operator instances, which leads to job failures. We 
> should detect and prevent the usage of singleton UDFs.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to