You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2022/08/19 21:25:47 UTC

[GitHub] [ozone] adoroszlai commented on a diff in pull request #3699: HDDS-7151. Avoid using GeneratedMessage in non-generated code

adoroszlai commented on code in PR #3699:
URL: https://github.com/apache/ozone/pull/3699#discussion_r950566220


##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/CodecRegistry.java:
##########
@@ -105,15 +109,17 @@ private <T> Codec getCodec(T object) throws IOException {
    */
   private <T> Codec getCodec(Class<T> format) throws IOException {
     Codec<T> codec;
-    if (valueCodecs.containsKey(format)) {
-      codec = (Codec<T>) valueCodecs.get(format);
-    } else if (valueCodecs.containsKey(format.getSuperclass())) {
-      codec = (Codec<T>) valueCodecs.get(format.getSuperclass());
-    } else {
-      throw new IllegalStateException(
-          "Codec is not registered for type: " + format);

Review Comment:
   > This adds codec support for interfaces implemented and not related to the Jira.
   
   It is related.  Generated c;ass for specific proto message extends `GeneratedMessage`, which implements `Message`.  
   So generated class doesn't directly implement `Message`.  Thus we need to lookup by interface implemented by parent/ancestor.



##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/CodecRegistry.java:
##########
@@ -105,15 +109,17 @@ private <T> Codec getCodec(T object) throws IOException {
    */
   private <T> Codec getCodec(Class<T> format) throws IOException {
     Codec<T> codec;
-    if (valueCodecs.containsKey(format)) {
-      codec = (Codec<T>) valueCodecs.get(format);
-    } else if (valueCodecs.containsKey(format.getSuperclass())) {
-      codec = (Codec<T>) valueCodecs.get(format.getSuperclass());
-    } else {
-      throw new IllegalStateException(
-          "Codec is not registered for type: " + format);

Review Comment:
   > This adds codec support for interfaces implemented and not related to the Jira.
   
   It is related.  Generated class for specific proto message extends `GeneratedMessage`, which implements `Message`.  
   So generated class doesn't directly implement `Message`.  Thus we need to lookup by interface implemented by parent/ancestor.



-- 
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@ozone.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org