Browse Source

HADOOP-530. Improve error messages in SequenceFile when keys or values are of the wrong type. Contributed by Hairong.

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@443467 13f79535-47bb-0310-9956-ffa450edef68
Doug Cutting 19 years ago
parent
commit
68ad09db38
2 changed files with 13 additions and 5 deletions
  1. 3 0
      CHANGES.txt
  2. 10 5
      src/java/org/apache/hadoop/io/SequenceFile.java

+ 3 - 0
CHANGES.txt

@@ -11,6 +11,9 @@ Trunk (unreleased changes)
    file format used to store pathnames has some limitations.
    (Wendy Chien via cutting)
 
+3. HADOOP-530.  Improve error messages in SequenceFile when keys or
+   values are of the wrong type.  (Hairong Kuang via cutting)
+
 
 Release 0.6.1 - 2006-08-13
 

+ 10 - 5
src/java/org/apache/hadoop/io/SequenceFile.java

@@ -528,9 +528,11 @@ public class SequenceFile {
     public synchronized void append(Writable key, Writable val)
       throws IOException {
       if (key.getClass() != keyClass)
-        throw new IOException("wrong key class: "+key+" is not "+keyClass);
+        throw new IOException("wrong key class: "+key.getClass().getName()
+            +" is not "+keyClass);
       if (val.getClass() != valClass)
-        throw new IOException("wrong value class: "+val+" is not "+valClass);
+        throw new IOException("wrong value class: "+val.getClass().getName()
+            +" is not "+valClass);
 
       buffer.reset();
 
@@ -643,9 +645,11 @@ public class SequenceFile {
     public synchronized void append(Writable key, Writable val)
       throws IOException {
       if (key.getClass() != keyClass)
-        throw new IOException("wrong key class: "+key+" is not "+keyClass);
+        throw new IOException("wrong key class: "+key.getClass().getName()
+            +" is not "+keyClass);
       if (val.getClass() != valClass)
-        throw new IOException("wrong value class: "+val+" is not "+valClass);
+        throw new IOException("wrong value class: "+val.getClass().getName()
+            +" is not "+valClass);
 
       buffer.reset();
 
@@ -1183,7 +1187,8 @@ public class SequenceFile {
      * value.  True if another entry exists, and false at end of file. */
     public synchronized boolean next(Writable key) throws IOException {
       if (key.getClass() != keyClass)
-        throw new IOException("wrong key class: "+key+" is not "+keyClass);
+        throw new IOException("wrong key class: "+key.getClass().getName()
+            +" is not "+keyClass);
 
       if (version < BLOCK_COMPRESS_VERSION || blockCompressed == false) {
         outBuf.reset();