[
https://issues.apache.org/jira/browse/FLINK-8264?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16290810#comment-16290810
]
ASF GitHub Bot commented on FLINK-8264:
---------------------------------------
GitHub user StephanEwen opened a pull request:
https://github.com/apache/flink/pull/5167
[FLINK-8264] [core] Add 'scala.' to the 'parent-first' classloading patterns
**BACKPORT of #5166 to release-1.4**
## What is the purpose of the change
Adding `scala.` to the "parent-first-patterns" makes sure that Scala
classes are not duplicated through "child-first" classloading when users
accidentally package the Scala Library into the application jar.
Since Scala classes traverse the boundary between core and user space, they
should never be duplicated.
## Brief change log
- Adds `scala.` to the default value of
`classloader.parent-first-patterns`.
## Verifying this change
This change can be verified as follows:
- Create a very simple quickstart Scala project using a Scala lambda for
a filter function (`_ => true`).
- Package it such that the Scala library is in the user code jar
- Without the fix, you get a weird class cast exception during
deserialization, with this fix, everything is fine.
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): (yes / **no)**
- The public API, i.e., is any changed class annotated with
`@Public(Evolving)`: (yes / **no**)
- The serializers: (yes / **no** / don't know)
- The runtime per-record code paths (performance sensitive): (yes /
**no** / don't know)
- Anything that affects deployment or recovery: JobManager (and its
components), Checkpointing, Yarn/Mesos, ZooKeeper: (yes / **no** / don't know)
- The S3 file system connector: (yes / **no** / don't know)
## Documentation
- Does this pull request introduce a new feature? (yes / **no**)
- If yes, how is the feature documented? (**not applicable** / docs /
JavaDocs / not documented)
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/StephanEwen/incubator-flink 8264_backport
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/flink/pull/5167.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 #5167
----
commit 8bd70c1e3d31f5c285ac5995504e52e39063e90b
Author: Stephan Ewen <[email protected]>
Date: 2017-12-14T12:50:39Z
[FLINK-8264] [core] Add 'scala.' to the 'parent-first' classloading
patterns.
----
> Add Scala to the parent-first loading patterns
> ----------------------------------------------
>
> Key: FLINK-8264
> URL: https://issues.apache.org/jira/browse/FLINK-8264
> Project: Flink
> Issue Type: Improvement
> Components: Core
> Affects Versions: 1.4.0
> Reporter: Stephan Ewen
> Assignee: Stephan Ewen
> Fix For: 1.5.0, 1.4.1
>
>
> A confusing experience happens when users accidentally package the Scala
> Library into their jar file. The reversed class loading duplicates Scala's
> classes, leading to exceptions like the one below.
> By adding {{scala.}} to the default 'parent-first-patterns' we can improve
> the user experience in such situations.
> Exception Stack Trace:
> {code}
> java.lang.ClassCastException: cannot assign instance of
> org.peopleinmotion.TestFunction$$anonfun$1 to field
> org.apache.flink.streaming.api.scala.DataStream$$anon$7.cleanFun$6 of type
> scala.Function1 in instance of
> org.apache.flink.streaming.api.scala.DataStream$$anon$7
> at
> java.io.ObjectStreamClass$FieldReflector.setObjFieldValues(ObjectStreamClass.java:2233)
> at
> java.io.ObjectStreamClass.setObjFieldValues(ObjectStreamClass.java:1405)
> at
> java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2288)
> at
> java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2206)
> at
> java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2064)
> at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1568)
> at
> java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2282)
> at
> java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2206)
> at
> java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2064)
> at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1568)
> at java.io.ObjectInputStream.readObject(ObjectInputStream.java:428)
> at
> org.apache.flink.util.InstantiationUtil.deserializeObject(InstantiationUtil.java:290)
> at
> org.apache.flink.util.InstantiationUtil.readObjectFromConfig(InstantiationUtil.java:248)
> at
> org.apache.flink.streaming.api.graph.StreamConfig.getStreamOperator(StreamConfig.java:220)
> ... 6 more
> {code}
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)