linu-shibu commented on code in PR #15620: URL: https://github.com/apache/kafka/pull/15620#discussion_r1573755412
########## storage/src/main/java/org/apache/kafka/server/log/remote/metadata/storage/serialization/RemoteLogMetadataSerde.java: ########## @@ -74,25 +72,24 @@ protected final Map<Short, RemoteLogMetadataTransform> createRemoteLogMetadataTr return map; } - protected final Map<String, Short> createRemoteLogStorageClassToApiKeyMap() { - Map<String, Short> map = new HashMap<>(); - map.put(RemoteLogSegmentMetadata.class.getName(), REMOTE_LOG_SEGMENT_METADATA_API_KEY); - map.put(RemoteLogSegmentMetadataUpdate.class.getName(), REMOTE_LOG_SEGMENT_METADATA_UPDATE_API_KEY); - map.put(RemotePartitionDeleteMetadata.class.getName(), REMOTE_PARTITION_DELETE_API_KEY); - map.put(RemoteLogSegmentMetadataSnapshot.class.getName(), REMOTE_LOG_SEGMENT_METADATA_SNAPSHOT_API_KEY); - return map; - } - public byte[] serialize(RemoteLogMetadata remoteLogMetadata) { - Short apiKey = remoteLogStorageClassToApiKey.get(remoteLogMetadata.getClass().getName()); - if (apiKey == null) { - throw new IllegalArgumentException("ApiKey for given RemoteStorageMetadata class: " + remoteLogMetadata.getClass() - + " does not exist."); - } - @SuppressWarnings("unchecked") - ApiMessageAndVersion apiMessageAndVersion = remoteLogMetadataTransform(apiKey).toApiMessageAndVersion(remoteLogMetadata); + RemoteLogMetadataTransform metadataTransform; + + if(remoteLogMetadata.getClass() == RemoteLogSegmentMetadata.class) { Review Comment: Okay, thanks for the clarification! I will change the comparison to use instanceof operator since it is already used in the project. -- 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org