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 2022/03/02 03:12:27 UTC

[GitHub] [flink] xintongsong commented on a change in pull request #18935: [FLINK-26347][rpc] Using system classloader in deserialization of Rem…

xintongsong commented on a change in pull request #18935:
URL: https://github.com/apache/flink/pull/18935#discussion_r817312657



##########
File path: flink-rpc/flink-rpc-core/src/main/java/org/apache/flink/runtime/rpc/messages/RemoteRpcInvocation.java
##########
@@ -108,129 +105,185 @@ public String toString() {
     // -------------------------------------------------------------------
 
     private void writeObject(ObjectOutputStream oos) throws IOException {
-        oos.writeUTF(declaringClassName);
-        oos.writeUTF(methodName);
+        // Translate it to byte array so that we can deserialize classes which cannot be found in
+        // akka class loader.
+        byte[] bytes = InstantiationUtil.serializeObject(methodInvocation);
+        oos.writeObject(bytes);
+    }
+
+    @SuppressWarnings("unchecked")
+    private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
+        byte[] bytes = (byte[]) ois.readObject();
+        methodInvocation =
+                InstantiationUtil.deserializeObject(bytes, ClassLoader.getSystemClassLoader());
+    }
+
+    // -------------------------------------------------------------------
+    // Utility classes
+    // -------------------------------------------------------------------
+
+    /** Wrapper class for the method invocation information. */
+    private static final class MethodInvocation implements Serializable {
+        private static final long serialVersionUID = 9187962608946082519L;

Review comment:
       ```suggestion
           private static final long serialVersionUID = 1L;
   ```

##########
File path: flink-rpc/flink-rpc-core/src/main/java/org/apache/flink/runtime/rpc/messages/RemoteRpcInvocation.java
##########
@@ -108,129 +105,185 @@ public String toString() {
     // -------------------------------------------------------------------
 
     private void writeObject(ObjectOutputStream oos) throws IOException {
-        oos.writeUTF(declaringClassName);
-        oos.writeUTF(methodName);
+        // Translate it to byte array so that we can deserialize classes which cannot be found in
+        // akka class loader.
+        byte[] bytes = InstantiationUtil.serializeObject(methodInvocation);
+        oos.writeObject(bytes);
+    }
+
+    @SuppressWarnings("unchecked")

Review comment:
       ```suggestion
   ```




-- 
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