[ https://issues.apache.org/jira/browse/FLINK-4883?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15651101#comment-15651101 ]
ASF GitHub Bot commented on FLINK-4883: --------------------------------------- Github user StefanRRichter commented on a diff in the pull request: https://github.com/apache/flink/pull/2729#discussion_r87201177 --- Diff: flink-java/src/main/java/org/apache/flink/api/java/ScalaObjectChecker.java --- @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.api.java; + +import org.apache.flink.annotation.Internal; +import org.apache.flink.api.common.InvalidProgramException; + +/** + * Scala Object checker tries to verify if a class is implemented by + * Scala Object + */ +@Internal +public class ScalaObjectChecker { + public static boolean isPotentialScalaObject(Object o) { --- End diff -- I think there might be a nicer/idiomatic way of doing this check through: ``` def isSingleton[A](a: A)(implicit ev: A <:< Singleton = null) = Option(ev).isDefined ``` > 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)