reswqa commented on code in PR #159:
URL: 
https://github.com/apache/flink-connector-elasticsearch/pull/159#discussion_r3534064411


##########
flink-connector-elasticsearch8/src/main/java/org/apache/flink/connector/elasticsearch/sink/OperationSerializer.java:
##########
@@ -36,7 +37,12 @@ public class OperationSerializer {
 
     public OperationSerializer() {
         kryo.setRegistrationRequired(false);
-        kryo.setInstantiatorStrategy(new StdInstantiatorStrategy());
+        DefaultInstantiatorStrategy instantiatorStrategy = new 
DefaultInstantiatorStrategy();
+        instantiatorStrategy.setFallbackInstantiatorStrategy(new 
StdInstantiatorStrategy());
+        kryo.setInstantiatorStrategy(instantiatorStrategy);

Review Comment:
   `DefaultInstantiatorStrategy` is the recommended way of creating objects 
with Kryo. It runs constructors just like would be done with Java code. 
`StdInstantiatorStrategy` uses JVM specific APIs to create an instance of a 
class without calling any constructor at all. Using this is dangerous because 
most classes expect their constructors to be called. Creating the object by 
bypassing its constructors may leave the object in an uninitialized or invalid 
state. 
(https://github.com/EsotericSoftware/kryo?tab=readme-ov-file#instantiatorstrategy)
   
   This address 
https://github.com/apache/flink-connector-elasticsearch/pull/136#issuecomment-3531739273



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to