Apache Nutch is an extensible and scalable web crawler
NUTCH-525 - DeleteDuplicates generates ArrayIndexOutOfBoundsException when trying to rerun dedup on a segment. Contributed by Vishal Shah.
Tacettin Guney7f060aa27531
diff --git a/CHANGES.txt b/CHANGES.txtindex 921ac1799..84fc86a1f 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -99,6 +99,9 @@ Unreleased changes (1.0-dev)33. NUTCH-516 - Next fetch time is not set when it is aCrawlDatum.STATUS_FETCH_GONE. (Emmanuel Joke via dogacan)+34. NUTCH-525 - DeleteDuplicates generates ArrayIndexOutOfBoundsException+ when trying to rerun dedup on a segment. (Vishal Shah via dogacan)+Release 0.9 - 2007-04-021. Changed log4j confiquration to log to stdout on commandlinediff --git a/src/java/org/apache/nutch/indexer/DeleteDuplicates.java b/src/java/org/apache/nutch/indexer/DeleteDuplicates.javaindex 62f353c98..39ca0c0bb 100644--- a/src/java/org/apache/nutch/indexer/DeleteDuplicates.java+++ b/src/java/org/apache/nutch/indexer/DeleteDuplicates.java@@ -182,7 +182,7 @@ public class DeleteDuplicates extends ToolBasereturn false;// skip deleted documents- while (indexReader.isDeleted(doc) && doc < maxDoc) doc++;+ while (doc < maxDoc && indexReader.isDeleted(doc)) doc++;if (doc >= maxDoc)return false;diff --git a/src/test/org/apache/nutch/indexer/TestDeleteDuplicates.java b/src/test/org/apache/nutch/indexer/TestDeleteDuplicates.javaindex 5b9179b98..22edf1e95 100644--- a/src/test/org/apache/nutch/indexer/TestDeleteDuplicates.java+++ b/src/test/org/apache/nutch/indexer/TestDeleteDuplicates.java@@ -42,6 +42,8 @@ public class TestDeleteDuplicates extends TestCase {Path index1;Path index2;Path index3;+ Path index4;+ Path index5;public void setUp() throws Exception {conf = NutchConfiguration.create();@@ -52,6 +54,8 @@ public class TestDeleteDuplicates extends TestCase {index1 = createIndex("index1", true, 1.0f, 10L, false);index2 = createIndex("index2", false, 2.0f, 20L, true);index3 = createIndex("index3", true, 1.0f, 10L, true);+ index4 = createSingleDocIndex("index4", 1.0f, 10L);+ index5 = createSingleDocIndex("index5", 1.0f, 20L);}private Path createIndex(String name, boolean hashDup, float inc, long time, boolean incFirst) throws Exception {@@ -80,6 +84,20 @@ public class TestDeleteDuplicates extends TestCase {return idx;}+ private Path createSingleDocIndex(String name, float inc, long time) throws Exception {+ Path idx = new Path(root, name);+ Path sub = new Path(idx, "part-0000");+ Directory dir = FSDirectory.getDirectory(sub.toString());+ IndexWriter writer = new IndexWriter(dir, new NutchDocumentAnalyzer(conf), true);+ Document doc = makeDoc(name,+ MD5Hash.digest("1").toString(),+ "http://www.example.com/1",+ 1.0f + inc, time + 1);+ writer.addDocument(doc);+ writer.close();+ return idx;+ }+private Document makeDoc(String segment, String digest, String url, float boost, long time) {Document doc = new Document();doc.add(new Field("segment", segment, Field.Store.YES, Field.Index.NO));@@ -173,4 +191,10 @@ public class TestDeleteDuplicates extends TestCase {reader.close();}+ public void testRededuplicate() throws Exception {+ DeleteDuplicates dedup = new DeleteDuplicates(conf);+ dedup.dedup(new Path[]{index4, index5});+ dedup.dedup(new Path[]{index4, index5});+ }+}