Zhangyx39 commented on a change in pull request #1426:
URL: https://github.com/apache/samza/pull/1426#discussion_r498420319



##########
File path: 
samza-core/src/main/java/org/apache/samza/serializers/IntermediateMessageSerde.java
##########
@@ -67,7 +67,20 @@ public IntermediateMessageSerde(Serde userMessageSerde) {
   public Object fromBytes(byte[] bytes) {
     try {
       final Object object;
-      final MessageType type = MessageType.values()[bytes[0]];
+      final MessageType type;
+      try {
+        type = MessageType.values()[bytes[0]];
+      } catch (ArrayIndexOutOfBoundsException e) {

Review comment:
       Sorry for the late reply. I moved the exception from the outer catch to 
here because I think:
   1. If this exception is triggered, the failure must be caused by the old 
format. The exception will tell the user exactly what is the issue.
   2. The chance of old message having a first byte of 0 to 2 is relatively 
small. In that case, users will still see the correct exception if they have 
multiple containers (with multiple exceptions) or if they look at the source 
code.
   3. New message with user serde error won't have this exception about message 
type. So users won't be misled by it. And I think this kind of failure is 
majority.
   




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

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


Reply via email to