kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jkr...@apache.org
Subject [1/4] git commit: KAFKA-1241 Better error message for underflow on read of struct.
Date Tue, 11 Feb 2014 04:59:40 GMT
Updated Branches:
  refs/heads/trunk 8014b6ff6 -> 6b80dbb97


KAFKA-1241 Better error message for underflow on read of struct.


Project: http://git-wip-us.apache.org/repos/asf/kafka/repo
Commit: http://git-wip-us.apache.org/repos/asf/kafka/commit/962b5475
Tree: http://git-wip-us.apache.org/repos/asf/kafka/tree/962b5475
Diff: http://git-wip-us.apache.org/repos/asf/kafka/diff/962b5475

Branch: refs/heads/trunk
Commit: 962b5475cbccfba7dbc424915fe517123f5e5203
Parents: 8014b6f
Author: Jay Kreps <jay.kreps@gmail.com>
Authored: Thu Feb 6 20:21:47 2014 -0800
Committer: Jay Kreps <jay.kreps@gmail.com>
Committed: Sun Feb 9 15:20:32 2014 -0800

----------------------------------------------------------------------
 .../org/apache/kafka/common/protocol/types/Schema.java    | 10 ++++++++--
 .../java/org/apache/kafka/common/protocol/types/Type.java |  1 -
 2 files changed, 8 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/962b5475/clients/src/main/java/org/apache/kafka/common/protocol/types/Schema.java
----------------------------------------------------------------------
diff --git a/clients/src/main/java/org/apache/kafka/common/protocol/types/Schema.java b/clients/src/main/java/org/apache/kafka/common/protocol/types/Schema.java
index c10d9ef..68b8827 100644
--- a/clients/src/main/java/org/apache/kafka/common/protocol/types/Schema.java
+++ b/clients/src/main/java/org/apache/kafka/common/protocol/types/Schema.java
@@ -62,8 +62,14 @@ public class Schema extends Type {
      */
     public Object read(ByteBuffer buffer) {
         Object[] objects = new Object[fields.length];
-        for (int i = 0; i < fields.length; i++)
-            objects[i] = fields[i].type.read(buffer);
+        for (int i = 0; i < fields.length; i++) {
+            try {
+                objects[i] = fields[i].type.read(buffer);
+            } catch (Exception e) {
+                throw new SchemaException("Error reading field '" + fields[i].name + "':
" + e.getMessage() == null ? e.getMessage()
+                                                                                        
                          : e.getClass().getName());
+            }
+        }
         return new Struct(this, objects);
     }
 

http://git-wip-us.apache.org/repos/asf/kafka/blob/962b5475/clients/src/main/java/org/apache/kafka/common/protocol/types/Type.java
----------------------------------------------------------------------
diff --git a/clients/src/main/java/org/apache/kafka/common/protocol/types/Type.java b/clients/src/main/java/org/apache/kafka/common/protocol/types/Type.java
index 1bd8ce4..f0d5a82 100644
--- a/clients/src/main/java/org/apache/kafka/common/protocol/types/Type.java
+++ b/clients/src/main/java/org/apache/kafka/common/protocol/types/Type.java
@@ -20,7 +20,6 @@ import java.nio.ByteBuffer;
 
 import org.apache.kafka.common.utils.Utils;
 
-
 /**
  * A serializable type
  */


Mime
View raw message