hadoop-hdfs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r1375338 - in /hadoop/common/branches/branch-2/hadoop-hdfs-project: ./ hadoop-hdfs/ hadoop-hdfs/src/main/java/ hadoop-hdfs/src/main/native/ hadoop-hdfs/src/main/webapps/datanode/ hadoop-hdfs/src/main/webapps/hdfs/ hadoop-hdfs/src/main/webap...
Date Tue, 21 Aug 2012 00:01:44 GMT
Author: eli
Date: Tue Aug 21 00:01:43 2012
New Revision: 1375338

URL: http://svn.apache.org/viewvc?rev=1375338&view=rev
Log:
HDFS-3707. TestFSInputChecker: improper use of skip. Contributed by Colin Patrick McCabe

Modified:
    hadoop/common/branches/branch-2/hadoop-hdfs-project/   (props changed)
    hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/   (props changed)
    hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
    hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/   (props
changed)
    hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/native/   (props
changed)
    hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/datanode/
  (props changed)
    hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/
  (props changed)
    hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/secondary/
  (props changed)
    hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/hdfs/   (props
changed)
    hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestFSInputChecker.java

Propchange: hadoop/common/branches/branch-2/hadoop-hdfs-project/
------------------------------------------------------------------------------
  Merged /hadoop/common/trunk/hadoop-hdfs-project:r1375336

Propchange: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/
------------------------------------------------------------------------------
  Merged /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs:r1375336

Modified: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt?rev=1375338&r1=1375337&r2=1375338&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt (original)
+++ hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt Tue Aug 21
00:01:43 2012
@@ -479,6 +479,9 @@ Release 2.0.1-alpha - UNRELEASED
     HDFS-3816. Invalidate work percentage default value should be 0.32f
     instead of 32. (Jing Zhao via suresh)
 
+    HDFS-3707. TestFSInputChecker: improper use of skip.
+    (Colin Patrick McCabe via eli)
+
   BREAKDOWN OF HDFS-3042 SUBTASKS
 
     HDFS-2185. HDFS portion of ZK-based FailoverController (todd)

Propchange: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/
------------------------------------------------------------------------------
  Merged /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java:r1375336

Propchange: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/native/
------------------------------------------------------------------------------
  Merged /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/native:r1375336

Propchange: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/datanode/
------------------------------------------------------------------------------
  Merged /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/datanode:r1375336

Propchange: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/
------------------------------------------------------------------------------
  Merged /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs:r1375336

Propchange: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/secondary/
------------------------------------------------------------------------------
  Merged /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/secondary:r1375336

Propchange: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/hdfs/
------------------------------------------------------------------------------
  Merged /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/hdfs:r1375336

Modified: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestFSInputChecker.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestFSInputChecker.java?rev=1375338&r1=1375337&r2=1375338&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestFSInputChecker.java
(original)
+++ hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestFSInputChecker.java
Tue Aug 21 00:01:43 2012
@@ -20,7 +20,9 @@ package org.apache.hadoop.hdfs;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
+import java.io.EOFException;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
@@ -159,8 +161,8 @@ public class TestFSInputChecker {
   private void testSkip1(int skippedBytes) 
   throws Exception {
     long oldPos = stm.getPos();
-    long nSkipped = stm.skip(skippedBytes);
-    long newPos = oldPos+nSkipped;
+    IOUtils.skipFully(stm, skippedBytes);
+    long newPos = oldPos + skippedBytes;
     assertEquals(stm.getPos(), newPos);
     stm.readFully(actual);
     checkAndEraseData(actual, (int)newPos, expected, "Read Sanity Test");
@@ -193,13 +195,31 @@ public class TestFSInputChecker {
     testSkip1(FILE_SIZE-1);
     
     stm.seek(0);
-    assertEquals(stm.skip(FILE_SIZE), FILE_SIZE);
-    assertEquals(stm.skip(10), 0);
+    IOUtils.skipFully(stm, FILE_SIZE);
+    try {
+      IOUtils.skipFully(stm, 10);
+      fail("expected to get a PrematureEOFException");
+    } catch (EOFException e) {
+      assertEquals(e.getMessage(), "Premature EOF from inputStream " +
+          "after skipping 0 byte(s).");
+    }
     
     stm.seek(0);
-    assertEquals(stm.skip(FILE_SIZE+10), FILE_SIZE);
+    try {
+      IOUtils.skipFully(stm, FILE_SIZE + 10);
+      fail("expected to get a PrematureEOFException");
+    } catch (EOFException e) {
+      assertEquals(e.getMessage(), "Premature EOF from inputStream " +
+          "after skipping " + FILE_SIZE + " byte(s).");
+    }
     stm.seek(10);
-    assertEquals(stm.skip(FILE_SIZE), FILE_SIZE-10);
+    try {
+      IOUtils.skipFully(stm, FILE_SIZE);
+      fail("expected to get a PrematureEOFException");
+    } catch (EOFException e) {
+      assertEquals(e.getMessage(), "Premature EOF from inputStream " +
+          "after skipping " + (FILE_SIZE - 10) + " byte(s).");
+    }
   }
 
   private void cleanupFile(FileSystem fileSys, Path name) throws IOException {



Mime
View raw message