flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FLINK-8836) Duplicating a KryoSerializer does not duplicate registered default serializers
Date Thu, 19 Apr 2018 14:58:00 GMT

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

ASF GitHub Bot commented on FLINK-8836:
---------------------------------------

Github user aljoscha commented on a diff in the pull request:

    https://github.com/apache/flink/pull/5880#discussion_r182776735
  
    --- Diff: flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoSerializer.java
---
    @@ -140,14 +140,37 @@ public KryoSerializer(Class<T> type, ExecutionConfig executionConfig){
     	 * Copy-constructor that does not copy transient fields. They will be initialized once
required.
     	 */
     	protected KryoSerializer(KryoSerializer<T> toCopy) {
    -		defaultSerializers = toCopy.defaultSerializers;
    -		defaultSerializerClasses = toCopy.defaultSerializerClasses;
     
    -		kryoRegistrations = toCopy.kryoRegistrations;
    +		this.type = checkNotNull(toCopy.type, "Type class cannot be null.");
    +		this.defaultSerializerClasses = toCopy.defaultSerializerClasses;
    +		this.defaultSerializers = new LinkedHashMap<>(toCopy.defaultSerializers.size());
    +		this.kryoRegistrations = new LinkedHashMap<>(toCopy.kryoRegistrations.size());
    +
    +		// deep copy the serializer instances in defaultSerializers
    +		for (Map.Entry<Class<?>, ExecutionConfig.SerializableSerializer<?>>
entry :
    +			toCopy.defaultSerializers.entrySet()) {
     
    -		type = toCopy.type;
    -		if(type == null){
    -			throw new NullPointerException("Type class cannot be null.");
    +			this.defaultSerializers.put(entry.getKey(), deepCopySerializer(entry.getValue()));
    +		}
    +
    +		// deep copy the serializer instances in kryoRegistrations
    +		for (Map.Entry<String, KryoRegistration> entry : toCopy.kryoRegistrations.entrySet())
{
    --- End diff --
    
    The problem is that we don't have the `ExecutionConfig` in the copy constructor.


> Duplicating a KryoSerializer does not duplicate registered default serializers
> ------------------------------------------------------------------------------
>
>                 Key: FLINK-8836
>                 URL: https://issues.apache.org/jira/browse/FLINK-8836
>             Project: Flink
>          Issue Type: Bug
>          Components: Type Serialization System
>            Reporter: Tzu-Li (Gordon) Tai
>            Assignee: Stefan Richter
>            Priority: Blocker
>             Fix For: 1.5.0
>
>
> The {{duplicate()}} method of the {{KryoSerializer}} is as following:
> {code:java}
> public KryoSerializer<T> duplicate() {
>     return new KryoSerializer<>(this);
> }
> protected KryoSerializer(KryoSerializer<T> toCopy) {
>     defaultSerializers = toCopy.defaultSerializers;
>     defaultSerializerClasses = toCopy.defaultSerializerClasses;
>     kryoRegistrations = toCopy.kryoRegistrations;
>     ...
> }
> {code}
> Shortly put, when duplicating a {{KryoSerializer}}, the {{defaultSerializers}} serializer
instances are directly provided to the new {{KryoSerializer}} instance.
>  This causes the fact that those default serializers are shared across two different
{{KryoSerializer}} instances, and therefore not a correct duplicate.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message