hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r539135 - in /lucene/hadoop/trunk: CHANGES.txt src/java/org/apache/hadoop/io/Text.java src/java/org/apache/hadoop/io/UTF8.java src/java/org/apache/hadoop/io/WritableUtils.java
Date Thu, 17 May 2007 21:53:43 GMT
Author: cutting
Date: Thu May 17 14:53:42 2007
New Revision: 539135

URL: http://svn.apache.org/viewvc?view=rev&rev=539135
Log:
HADOOP-1361.  Fix various calls to skipBytes() to check the return value.  Contributed by
Hairong.

Modified:
    lucene/hadoop/trunk/CHANGES.txt
    lucene/hadoop/trunk/src/java/org/apache/hadoop/io/Text.java
    lucene/hadoop/trunk/src/java/org/apache/hadoop/io/UTF8.java
    lucene/hadoop/trunk/src/java/org/apache/hadoop/io/WritableUtils.java

Modified: lucene/hadoop/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/CHANGES.txt?view=diff&rev=539135&r1=539134&r2=539135
==============================================================================
--- lucene/hadoop/trunk/CHANGES.txt (original)
+++ lucene/hadoop/trunk/CHANGES.txt Thu May 17 14:53:42 2007
@@ -428,6 +428,9 @@
 120. HADOOP-1369.  Fix inconsistent synchronization in TaskTracker.
      (omalley via cutting)
 
+121. HADOOP-1361.  Fix various calls to skipBytes() to check return
+     value. (Hairong Kuang via cutting)
+
 
 Release 0.12.3 - 2007-04-06
 

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/io/Text.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/io/Text.java?view=diff&rev=539135&r1=539134&r2=539135
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/io/Text.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/io/Text.java Thu May 17 14:53:42 2007
@@ -230,7 +230,7 @@
   /** Skips over one Text in the input. */
   public static void skip(DataInput in) throws IOException {
     int length = WritableUtils.readVInt(in);
-    in.skipBytes(length);
+    WritableUtils.skipFully(in, length);
   }
 
   /** serialize

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/io/UTF8.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/io/UTF8.java?view=diff&rev=539135&r1=539134&r2=539135
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/io/UTF8.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/io/UTF8.java Thu May 17 14:53:42 2007
@@ -110,7 +110,7 @@
   /** Skips over one UTF8 in the input. */
   public static void skip(DataInput in) throws IOException {
     int length = in.readUnsignedShort();
-    in.skipBytes(length);
+    WritableUtils.skipFully(in, length);
   }
 
   public void write(DataOutput out) throws IOException {

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/io/WritableUtils.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/io/WritableUtils.java?view=diff&rev=539135&r1=539134&r2=539135
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/io/WritableUtils.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/io/WritableUtils.java Thu May 17 14:53:42
2007
@@ -48,7 +48,9 @@
 
   public static void skipCompressedByteArray(DataInput in) throws IOException {
     int length = in.readInt();
-    if (length != -1) in.skipBytes(length);
+    if (length != -1) {
+      skipFully(in, length);
+    }
   }
 
   public static int  writeCompressedByteArray(DataOutput out, byte[] bytes) throws IOException
{
@@ -381,5 +383,24 @@
   public static void writeEnum(DataOutput out,  Enum enumVal) 
     throws IOException{
     Text.writeString(out, enumVal.name()); 
+  }
+  /**
+   * Skip <i>len</i> number of bytes in input stream<i>in</i>
+   * @param in input stream
+   * @param len number of bytes to skip
+   * @throws IOException when skipped less number of bytes
+   */
+  public static void skipFully(DataInput in, int len) throws IOException {
+    int total = 0;
+    int cur = 0;
+
+    while ((total<len) && ((cur = (int) in.skipBytes(len-total)) > 0)) {
+        total += cur;
+    }
+
+    if (total<len) {
+      throw new IOException("Not able to skip " + len + " bytes, possibly " +
+                            "due to end of input.");
+    }
   }
 }



Mime
View raw message