szetszwo commented on code in PR #9733:
URL: https://github.com/apache/ozone/pull/9733#discussion_r2806853805


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/io/ByteStringCodec.java:
##########
@@ -19,21 +19,24 @@
 
 import org.apache.ratis.thirdparty.com.google.protobuf.ByteString;
 import 
org.apache.ratis.thirdparty.com.google.protobuf.InvalidProtocolBufferException;
+import org.apache.ratis.thirdparty.com.google.protobuf.UnsafeByteOperations;
 
 /**
- * A dummy codec that serializes a ByteString object to ByteString.
+ * {@link Codec} implementation for non-shaded
+ * {@link com.google.protobuf.ByteString} objects.
  */
 public class ByteStringCodec implements Codec {
 
   @Override
   public ByteString serialize(Object object)
       throws InvalidProtocolBufferException {
-    return (ByteString) object;
+    return UnsafeByteOperations.unsafeWrap(
+        ((com.google.protobuf.ByteString) object).asReadOnlyByteBuffer());
   }
 
   @Override
   public Object deserialize(Class<?> type, ByteString value)
       throws InvalidProtocolBufferException {
-    return value;
+    return com.google.protobuf.ByteString.copyFrom(value.toByteArray());

Review Comment:
   Use `com.google.protobuf.UnsafeByteOperations`.
   



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to