You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2021/10/01 07:27:20 UTC

[GitHub] [flink] zentol opened a new pull request #17402: [24017] Setup Kryo to be usable without flink-scala

zentol opened a new pull request #17402:
URL: https://github.com/apache/flink/pull/17402


   With this PR Kryo works in a backwards-compatible fashion even if flink-scala is not on the classpath.
   To that end the java-related serializers were moved to flink-java to remain accessible in that scenario, and the registration IDs of the java serializers and custom user-defined serializers were pinned such that they remain identical.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] igalshilman commented on a change in pull request #17402: [FLINK-24017] Setup Kryo to be usable without flink-scala

Posted by GitBox <gi...@apache.org>.
igalshilman commented on a change in pull request #17402:
URL: https://github.com/apache/flink/pull/17402#discussion_r728902355



##########
File path: flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/KryoUtils.java
##########
@@ -90,28 +90,32 @@
      * Apply a list of {@link KryoRegistration} to a Kryo instance. The list of registrations is
      * assumed to already be a final resolution of all possible registration overwrites.
      *
-     * <p>The registrations are applied in the given order and always specify the registration id as
-     * the next available id in the Kryo instance (providing the id just extra ensures nothing is
-     * overwritten, and isn't strictly required);
+     * <p>The registrations are applied in the given order and always specify the registration id,
+     * using the given {@code firstRegistrationId} and incrementing it for each registration.
      *
      * @param kryo the Kryo instance to apply the registrations
      * @param resolvedRegistrations the registrations, which should already be resolved of all
      *     possible registration overwrites
+     * @param firstRegistrationId the first registration id to use
      */
     public static void applyRegistrations(
-            Kryo kryo, Collection<KryoRegistration> resolvedRegistrations) {
+            Kryo kryo,
+            Collection<KryoRegistration> resolvedRegistrations,
+            int firstRegistrationId) {
 
+        int currentRegistrationId = firstRegistrationId;
         Serializer<?> serializer;
         for (KryoRegistration registration : resolvedRegistrations) {
             serializer = registration.getSerializer(kryo);
 
             if (serializer != null) {
-                kryo.register(
-                        registration.getRegisteredClass(),
-                        serializer,
-                        kryo.getNextRegistrationId());
+                kryo.register(registration.getRegisteredClass(), serializer, currentRegistrationId);
             } else {
-                kryo.register(registration.getRegisteredClass(), kryo.getNextRegistrationId());
+                kryo.register(registration.getRegisteredClass(), currentRegistrationId);
+            }
+            // if Kryo already had a serializer for that type then it ignores the registration
+            if (kryo.getRegistration(currentRegistrationId) != null) {

Review comment:
       @zentol this `if` is positioned in a suspicious place. could it ever be `== null` ?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #17402: [FLINK-24017] Setup Kryo to be usable without flink-scala

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #17402:
URL: https://github.com/apache/flink/pull/17402#issuecomment-931990331


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "836ebdb4c157f535f9bfee1444b3df0be9fc70ed",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=24693",
       "triggerID" : "836ebdb4c157f535f9bfee1444b3df0be9fc70ed",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 836ebdb4c157f535f9bfee1444b3df0be9fc70ed Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=24693) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run azure` re-run the last Azure build
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] dmvk commented on a change in pull request #17402: [FLINK-24017] Setup Kryo to be usable without flink-scala

Posted by GitBox <gi...@apache.org>.
dmvk commented on a change in pull request #17402:
URL: https://github.com/apache/flink/pull/17402#discussion_r725921039



##########
File path: flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoSerializer.java
##########
@@ -86,6 +117,23 @@
         configureKryoLogging();
     }
 
+    @Nullable
+    private static final ChillSerializerRegistrar flinkChillPackageRegistrar =

Review comment:
       nit: uppercase variable name

##########
File path: flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoSerializer.java
##########
@@ -45,6 +45,8 @@
 import org.slf4j.Logger;

Review comment:
       OT: There are these legacy fields, starting on L166. Is there anything keeping us from removing them?

##########
File path: flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoSerializer.java
##########
@@ -67,6 +69,35 @@
  * <p>This serializer is intended as a fallback serializer for the cases that are not covered by the
  * basic types, tuples, and POJOs.
  *
+ * <p>The set of serializers registered with Kryo via {@link Kryo#register}, with their respective
+ * IDs, depends on whether flink-java or flink-scala are on the classpath. This is for
+ * backwards-compatibility reasons.
+ *
+ * <p>If neither are available (which should only apply to tests in flink-core), then:
+ *
+ * <ul>
+ *   <li>0-9 are used for Java primitives
+ *   <li>10+ are used for user-defined registration
+ * </ul>
+ *
+ * <p>If flink-scala is available, then:
+ *
+ * <ul>
+ *   <li>0-9 are used for Java primitives
+ *   <li>10-72 are used for Scala classes
+ *   <li>73-84 are used for Java classes
+ *   <li>85+ are used for user-defined registration
+ * </ul>

Review comment:
       Should we introduce a safeguard for these boundaries? (we only enforce the lower boundary now)

##########
File path: flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoSerializer.java
##########
@@ -67,6 +69,35 @@
  * <p>This serializer is intended as a fallback serializer for the cases that are not covered by the
  * basic types, tuples, and POJOs.
  *
+ * <p>The set of serializers registered with Kryo via {@link Kryo#register}, with their respective
+ * IDs, depends on whether flink-java or flink-scala are on the classpath. This is for
+ * backwards-compatibility reasons.
+ *
+ * <p>If neither are available (which should only apply to tests in flink-core), then:
+ *
+ * <ul>
+ *   <li>0-9 are used for Java primitives
+ *   <li>10+ are used for user-defined registration
+ * </ul>
+ *
+ * <p>If flink-scala is available, then:
+ *
+ * <ul>
+ *   <li>0-9 are used for Java primitives
+ *   <li>10-72 are used for Scala classes
+ *   <li>73-84 are used for Java classes
+ *   <li>85+ are used for user-defined registration
+ * </ul>
+ *
+ * <p>If *only* flink-java is available, then:
+ *
+ * <ul>
+ *   <li>0-9 are used for Java primitives
+ *   <li>10-72 are unused (to maintain compatibility)
+ *   <li>73-84 are used for Java classes
+ *   <li>85+ are used for user-defined registration

Review comment:
       OT: It would be nice to have a free range for registrations we may want to add in the future without breaking the compatibility.
   
   It's just something to keep in mind, as we can not easily introduce this now, but if we ever break the compatibility in the future, it may be worth adding it.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] zentol commented on a change in pull request #17402: [FLINK-24017] Setup Kryo to be usable without flink-scala

Posted by GitBox <gi...@apache.org>.
zentol commented on a change in pull request #17402:
URL: https://github.com/apache/flink/pull/17402#discussion_r726162667



##########
File path: flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoSerializer.java
##########
@@ -45,6 +45,8 @@
 import org.slf4j.Logger;

Review comment:
       They are kept for binary backwards compatibility.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] dmvk commented on pull request #17402: [FLINK-24017] Setup Kryo to be usable without flink-scala

Posted by GitBox <gi...@apache.org>.
dmvk commented on pull request #17402:
URL: https://github.com/apache/flink/pull/17402#issuecomment-942219867


   > We already have plenty of such test-cases. Like the KryoSerializerCompatibilityTest or KryoSerializerRegistrationsTest.
   
   Great, the `KryoSerializerRegistrationsTest` seems to be covering this well. 👍 Maybe we could extend it a bit by registering a custom type and checking it starts at index 85, but no hard feelings if we don't.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] zentol commented on a change in pull request #17402: [FLINK-24017] Setup Kryo to be usable without flink-scala

Posted by GitBox <gi...@apache.org>.
zentol commented on a change in pull request #17402:
URL: https://github.com/apache/flink/pull/17402#discussion_r726172216



##########
File path: flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoSerializer.java
##########
@@ -67,6 +69,35 @@
  * <p>This serializer is intended as a fallback serializer for the cases that are not covered by the
  * basic types, tuples, and POJOs.
  *
+ * <p>The set of serializers registered with Kryo via {@link Kryo#register}, with their respective
+ * IDs, depends on whether flink-java or flink-scala are on the classpath. This is for
+ * backwards-compatibility reasons.
+ *
+ * <p>If neither are available (which should only apply to tests in flink-core), then:
+ *
+ * <ul>
+ *   <li>0-9 are used for Java primitives
+ *   <li>10+ are used for user-defined registration
+ * </ul>
+ *
+ * <p>If flink-scala is available, then:
+ *
+ * <ul>
+ *   <li>0-9 are used for Java primitives
+ *   <li>10-72 are used for Scala classes
+ *   <li>73-84 are used for Java classes
+ *   <li>85+ are used for user-defined registration
+ * </ul>

Review comment:
       Existing tests cover this quite well already; if you go over the boundary you mess up the next serializer range and thus break deserialization of existing snapshots.
   
   I did think about enforcing these limits at runtime but it seemed pointless because at that point we've already messed up big time and this must be caught earlier.
   I thought about specific tests for the ranges, but it wouldn't catch anything that existing tests aren't already catching.
   
   




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #17402: [24017] Setup Kryo to be usable without flink-scala

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #17402:
URL: https://github.com/apache/flink/pull/17402#issuecomment-931990331


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "836ebdb4c157f535f9bfee1444b3df0be9fc70ed",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=24693",
       "triggerID" : "836ebdb4c157f535f9bfee1444b3df0be9fc70ed",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 836ebdb4c157f535f9bfee1444b3df0be9fc70ed Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=24693) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] flinkbot commented on pull request #17402: [24017] Setup Kryo to be usable without flink-scala

Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #17402:
URL: https://github.com/apache/flink/pull/17402#issuecomment-931990331


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "836ebdb4c157f535f9bfee1444b3df0be9fc70ed",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "836ebdb4c157f535f9bfee1444b3df0be9fc70ed",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 836ebdb4c157f535f9bfee1444b3df0be9fc70ed UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] zentol commented on a change in pull request #17402: [FLINK-24017] Setup Kryo to be usable without flink-scala

Posted by GitBox <gi...@apache.org>.
zentol commented on a change in pull request #17402:
URL: https://github.com/apache/flink/pull/17402#discussion_r726164495



##########
File path: flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoSerializer.java
##########
@@ -67,6 +69,35 @@
  * <p>This serializer is intended as a fallback serializer for the cases that are not covered by the
  * basic types, tuples, and POJOs.
  *
+ * <p>The set of serializers registered with Kryo via {@link Kryo#register}, with their respective
+ * IDs, depends on whether flink-java or flink-scala are on the classpath. This is for
+ * backwards-compatibility reasons.
+ *
+ * <p>If neither are available (which should only apply to tests in flink-core), then:
+ *
+ * <ul>
+ *   <li>0-9 are used for Java primitives
+ *   <li>10+ are used for user-defined registration
+ * </ul>
+ *
+ * <p>If flink-scala is available, then:
+ *
+ * <ul>
+ *   <li>0-9 are used for Java primitives
+ *   <li>10-72 are used for Scala classes
+ *   <li>73-84 are used for Java classes
+ *   <li>85+ are used for user-defined registration
+ * </ul>
+ *
+ * <p>If *only* flink-java is available, then:
+ *
+ * <ul>
+ *   <li>0-9 are used for Java primitives
+ *   <li>10-72 are unused (to maintain compatibility)
+ *   <li>73-84 are used for Java classes
+ *   <li>85+ are used for user-defined registration

Review comment:
       Yeah I had the same thought while working on this. At least we have now at least the possibility to define such ranges; small steps...




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] zentol commented on a change in pull request #17402: [FLINK-24017] Setup Kryo to be usable without flink-scala

Posted by GitBox <gi...@apache.org>.
zentol commented on a change in pull request #17402:
URL: https://github.com/apache/flink/pull/17402#discussion_r726166373



##########
File path: flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoSerializer.java
##########
@@ -86,6 +117,23 @@
         configureKryoLogging();
     }
 
+    @Nullable
+    private static final ChillSerializerRegistrar flinkChillPackageRegistrar =

Review comment:
       we only enforce that naming schema for public variables (for better or worse)




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] flinkbot edited a comment on pull request #17402: [FLINK-24017] Setup Kryo to be usable without flink-scala

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #17402:
URL: https://github.com/apache/flink/pull/17402#issuecomment-931990331


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "836ebdb4c157f535f9bfee1444b3df0be9fc70ed",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=24693",
       "triggerID" : "836ebdb4c157f535f9bfee1444b3df0be9fc70ed",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 836ebdb4c157f535f9bfee1444b3df0be9fc70ed Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=24693) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] zentol edited a comment on pull request #17402: [FLINK-24017] Setup Kryo to be usable without flink-scala

Posted by GitBox <gi...@apache.org>.
zentol edited a comment on pull request #17402:
URL: https://github.com/apache/flink/pull/17402#issuecomment-940074506


   > Also it would be great if we could have a test case, that this is fully compatible with the 1.14 KryoSerializer, but this would be quite tricky to do. Only simple approach I can think of would be writing some binary file with 1.14 version that we'd distribute with 1.15+ test suite, which is quite ugly :/
   
   We already have plenty of such test-cases. Like the KryoSerializerCompatibilityTest or KryoSerializerRegistrationsTest.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] zentol commented on a change in pull request #17402: [FLINK-24017] Setup Kryo to be usable without flink-scala

Posted by GitBox <gi...@apache.org>.
zentol commented on a change in pull request #17402:
URL: https://github.com/apache/flink/pull/17402#discussion_r726164495



##########
File path: flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoSerializer.java
##########
@@ -67,6 +69,35 @@
  * <p>This serializer is intended as a fallback serializer for the cases that are not covered by the
  * basic types, tuples, and POJOs.
  *
+ * <p>The set of serializers registered with Kryo via {@link Kryo#register}, with their respective
+ * IDs, depends on whether flink-java or flink-scala are on the classpath. This is for
+ * backwards-compatibility reasons.
+ *
+ * <p>If neither are available (which should only apply to tests in flink-core), then:
+ *
+ * <ul>
+ *   <li>0-9 are used for Java primitives
+ *   <li>10+ are used for user-defined registration
+ * </ul>
+ *
+ * <p>If flink-scala is available, then:
+ *
+ * <ul>
+ *   <li>0-9 are used for Java primitives
+ *   <li>10-72 are used for Scala classes
+ *   <li>73-84 are used for Java classes
+ *   <li>85+ are used for user-defined registration
+ * </ul>
+ *
+ * <p>If *only* flink-java is available, then:
+ *
+ * <ul>
+ *   <li>0-9 are used for Java primitives
+ *   <li>10-72 are unused (to maintain compatibility)
+ *   <li>73-84 are used for Java classes
+ *   <li>85+ are used for user-defined registration

Review comment:
       Yeah I had the same thought while working on this. At least we have now at least the possibility to define such ranges; little steps...




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] zentol commented on a change in pull request #17402: [FLINK-24017] Setup Kryo to be usable without flink-scala

Posted by GitBox <gi...@apache.org>.
zentol commented on a change in pull request #17402:
URL: https://github.com/apache/flink/pull/17402#discussion_r728979086



##########
File path: flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/KryoUtils.java
##########
@@ -90,28 +90,32 @@
      * Apply a list of {@link KryoRegistration} to a Kryo instance. The list of registrations is
      * assumed to already be a final resolution of all possible registration overwrites.
      *
-     * <p>The registrations are applied in the given order and always specify the registration id as
-     * the next available id in the Kryo instance (providing the id just extra ensures nothing is
-     * overwritten, and isn't strictly required);
+     * <p>The registrations are applied in the given order and always specify the registration id,
+     * using the given {@code firstRegistrationId} and incrementing it for each registration.
      *
      * @param kryo the Kryo instance to apply the registrations
      * @param resolvedRegistrations the registrations, which should already be resolved of all
      *     possible registration overwrites
+     * @param firstRegistrationId the first registration id to use
      */
     public static void applyRegistrations(
-            Kryo kryo, Collection<KryoRegistration> resolvedRegistrations) {
+            Kryo kryo,
+            Collection<KryoRegistration> resolvedRegistrations,
+            int firstRegistrationId) {
 
+        int currentRegistrationId = firstRegistrationId;
         Serializer<?> serializer;
         for (KryoRegistration registration : resolvedRegistrations) {
             serializer = registration.getSerializer(kryo);
 
             if (serializer != null) {
-                kryo.register(
-                        registration.getRegisteredClass(),
-                        serializer,
-                        kryo.getNextRegistrationId());
+                kryo.register(registration.getRegisteredClass(), serializer, currentRegistrationId);
             } else {
-                kryo.register(registration.getRegisteredClass(), kryo.getNextRegistrationId());
+                kryo.register(registration.getRegisteredClass(), currentRegistrationId);
+            }
+            // if Kryo already had a serializer for that type then it ignores the registration
+            if (kryo.getRegistration(currentRegistrationId) != null) {

Review comment:
       yes it can be null, if the type you registered was already registered under a different registration id. In that case Kryo ignores the registration, and since nothing was registered in this case, no registration will be found for the `currentRegistrationId`.
   
   
   




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] igalshilman commented on a change in pull request #17402: [FLINK-24017] Setup Kryo to be usable without flink-scala

Posted by GitBox <gi...@apache.org>.
igalshilman commented on a change in pull request #17402:
URL: https://github.com/apache/flink/pull/17402#discussion_r728902355



##########
File path: flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/KryoUtils.java
##########
@@ -90,28 +90,32 @@
      * Apply a list of {@link KryoRegistration} to a Kryo instance. The list of registrations is
      * assumed to already be a final resolution of all possible registration overwrites.
      *
-     * <p>The registrations are applied in the given order and always specify the registration id as
-     * the next available id in the Kryo instance (providing the id just extra ensures nothing is
-     * overwritten, and isn't strictly required);
+     * <p>The registrations are applied in the given order and always specify the registration id,
+     * using the given {@code firstRegistrationId} and incrementing it for each registration.
      *
      * @param kryo the Kryo instance to apply the registrations
      * @param resolvedRegistrations the registrations, which should already be resolved of all
      *     possible registration overwrites
+     * @param firstRegistrationId the first registration id to use
      */
     public static void applyRegistrations(
-            Kryo kryo, Collection<KryoRegistration> resolvedRegistrations) {
+            Kryo kryo,
+            Collection<KryoRegistration> resolvedRegistrations,
+            int firstRegistrationId) {
 
+        int currentRegistrationId = firstRegistrationId;
         Serializer<?> serializer;
         for (KryoRegistration registration : resolvedRegistrations) {
             serializer = registration.getSerializer(kryo);
 
             if (serializer != null) {
-                kryo.register(
-                        registration.getRegisteredClass(),
-                        serializer,
-                        kryo.getNextRegistrationId());
+                kryo.register(registration.getRegisteredClass(), serializer, currentRegistrationId);
             } else {
-                kryo.register(registration.getRegisteredClass(), kryo.getNextRegistrationId());
+                kryo.register(registration.getRegisteredClass(), currentRegistrationId);
+            }
+            // if Kryo already had a serializer for that type then it ignores the registration
+            if (kryo.getRegistration(currentRegistrationId) != null) {

Review comment:
       @zentol this `if` is positioned in a suspicious place. could it ever be `!= null` ?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] flinkbot commented on pull request #17402: [24017] Setup Kryo to be usable without flink-scala

Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #17402:
URL: https://github.com/apache/flink/pull/17402#issuecomment-931980698


   Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community
   to review your pull request. We will use this comment to track the progress of the review.
   
   
   ## Automated Checks
   Last check on commit 836ebdb4c157f535f9bfee1444b3df0be9fc70ed (Fri Oct 01 07:30:41 UTC 2021)
   
   **Warnings:**
    * **1 pom.xml files were touched**: Check for build and licensing issues.
    * No documentation files were touched! Remember to keep the Flink docs up to date!
    * **Invalid pull request title: No valid Jira ID provided**
   
   
   <sub>Mention the bot in a comment to re-run the automated checks.</sub>
   ## Review Progress
   
   * ❓ 1. The [description] looks good.
   * ❓ 2. There is [consensus] that the contribution should go into to Flink.
   * ❓ 3. Needs [attention] from.
   * ❓ 4. The change fits into the overall [architecture].
   * ❓ 5. Overall code [quality] is good.
   
   Please see the [Pull Request Review Guide](https://flink.apache.org/contributing/reviewing-prs.html) for a full explanation of the review process.<details>
    The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot approve description` to approve one or more aspects (aspects: `description`, `consensus`, `architecture` and `quality`)
    - `@flinkbot approve all` to approve all aspects
    - `@flinkbot approve-until architecture` to approve everything until `architecture`
    - `@flinkbot attention @username1 [@username2 ..]` to require somebody's attention
    - `@flinkbot disapprove architecture` to remove an approval you gave earlier
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] dmvk commented on pull request #17402: [FLINK-24017] Setup Kryo to be usable without flink-scala

Posted by GitBox <gi...@apache.org>.
dmvk commented on pull request #17402:
URL: https://github.com/apache/flink/pull/17402#issuecomment-942219867


   > We already have plenty of such test-cases. Like the KryoSerializerCompatibilityTest or KryoSerializerRegistrationsTest.
   
   Great, the `KryoSerializerRegistrationsTest` seems to be covering this well. 👍 Maybe we could extend it a bit by registering a custom type and checking it starts at index 85, but no hard feelings if we don't.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] zentol commented on pull request #17402: [FLINK-24017] Setup Kryo to be usable without flink-scala

Posted by GitBox <gi...@apache.org>.
zentol commented on pull request #17402:
URL: https://github.com/apache/flink/pull/17402#issuecomment-940074506


   > Also it would be great if we could have a test case, that this is fully compatible with the 1.14 KryoSerializer, but this would be quite tricky to do. Only simple approach I can think of would be writing some binary file with 1.14 version that we'd distribute with 1.15+ test suite, which is quite ugly :/
   
   We already have plenty of such test-cases.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [flink] zentol merged pull request #17402: [FLINK-24017] Setup Kryo to be usable without flink-scala

Posted by GitBox <gi...@apache.org>.
zentol merged pull request #17402:
URL: https://github.com/apache/flink/pull/17402


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org