Index: solr/core/src/test/org/apache/solr/core/FakeDeletionPolicy.java
===================================================================
--- solr/core/src/test/org/apache/solr/core/FakeDeletionPolicy.java	(révision 1461535)
+++ solr/core/src/test/org/apache/solr/core/FakeDeletionPolicy.java	(copie de travail)
@@ -26,7 +26,7 @@
 /**
  *
  */
-public class FakeDeletionPolicy implements IndexDeletionPolicy, NamedListInitializedPlugin {
+public class FakeDeletionPolicy extends IndexDeletionPolicy implements NamedListInitializedPlugin {
 
   private String var1;
   private String var2;
Index: solr/core/src/java/org/apache/solr/core/IndexDeletionPolicyWrapper.java
===================================================================
--- solr/core/src/java/org/apache/solr/core/IndexDeletionPolicyWrapper.java	(révision 1461535)
+++ solr/core/src/java/org/apache/solr/core/IndexDeletionPolicyWrapper.java	(copie de travail)
@@ -36,7 +36,7 @@
  *
  * @see org.apache.lucene.index.IndexDeletionPolicy
  */
-public class IndexDeletionPolicyWrapper implements IndexDeletionPolicy {
+public final class IndexDeletionPolicyWrapper extends IndexDeletionPolicy {
   private final IndexDeletionPolicy deletionPolicy;
   private volatile Map<Long, IndexCommit> solrVersionVsCommits = new ConcurrentHashMap<Long, IndexCommit>();
   private final Map<Long, Long> reserves = new ConcurrentHashMap<Long,Long>();
@@ -244,5 +244,10 @@
       return 0;
     }
   }
+
+  @Override
+  public IndexDeletionPolicy clone() {
+    return new IndexDeletionPolicyWrapper(deletionPolicy);
+  }
 }
 
Index: solr/core/src/java/org/apache/solr/core/SolrDeletionPolicy.java
===================================================================
--- solr/core/src/java/org/apache/solr/core/SolrDeletionPolicy.java	(révision 1461535)
+++ solr/core/src/java/org/apache/solr/core/SolrDeletionPolicy.java	(copie de travail)
@@ -41,7 +41,7 @@
  *
  * @see org.apache.lucene.index.IndexDeletionPolicy
  */
-public class SolrDeletionPolicy implements IndexDeletionPolicy, NamedListInitializedPlugin {
+public class SolrDeletionPolicy extends IndexDeletionPolicy implements NamedListInitializedPlugin {
   public static Logger log = LoggerFactory.getLogger(SolrCore.class);
 
   private String maxCommitAge = null;
Index: lucene/core/src/test/org/apache/lucene/index/TestPersistentSnapshotDeletionPolicy.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestPersistentSnapshotDeletionPolicy.java	(révision 1461535)
+++ lucene/core/src/test/org/apache/lucene/index/TestPersistentSnapshotDeletionPolicy.java	(copie de travail)
@@ -25,7 +25,6 @@
 import org.apache.lucene.index.IndexWriterConfig.OpenMode;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.LockObtainFailedException;
-import org.apache.lucene.store.MockDirectoryWrapper;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -79,8 +78,8 @@
   public void testExistingSnapshots() throws Exception {
     int numSnapshots = 3;
     Directory dir = newDirectory();
-    PersistentSnapshotDeletionPolicy psdp = (PersistentSnapshotDeletionPolicy) getDeletionPolicy();
-    IndexWriter writer = new IndexWriter(dir, getConfig(random(), psdp));
+    IndexWriter writer = new IndexWriter(dir, getConfig(random(), getDeletionPolicy()));
+    PersistentSnapshotDeletionPolicy psdp = (PersistentSnapshotDeletionPolicy) writer.getConfig().getIndexDeletionPolicy();
     prepareIndexAndSnapshots(psdp, writer, numSnapshots, "snapshot");
     writer.close();
     psdp.close();
@@ -143,8 +142,8 @@
   @Test
   public void testSnapshotRelease() throws Exception {
     Directory dir = newDirectory();
-    PersistentSnapshotDeletionPolicy psdp = (PersistentSnapshotDeletionPolicy) getDeletionPolicy();
-    IndexWriter writer = new IndexWriter(dir, getConfig(random(), psdp));
+    IndexWriter writer = new IndexWriter(dir, getConfig(random(), getDeletionPolicy()));
+    PersistentSnapshotDeletionPolicy psdp = (PersistentSnapshotDeletionPolicy) writer.getConfig().getIndexDeletionPolicy();
     prepareIndexAndSnapshots(psdp, writer, 1, "snapshot");
     writer.close();
 
@@ -166,8 +165,8 @@
     // static read method works.
     int numSnapshots = 1;
     Directory dir = newDirectory();
-    PersistentSnapshotDeletionPolicy psdp = (PersistentSnapshotDeletionPolicy) getDeletionPolicy();
-    IndexWriter writer = new IndexWriter(dir, getConfig(random(), psdp));
+    IndexWriter writer = new IndexWriter(dir, getConfig(random(), getDeletionPolicy()));
+    PersistentSnapshotDeletionPolicy psdp = (PersistentSnapshotDeletionPolicy) writer.getConfig().getIndexDeletionPolicy();
     prepareIndexAndSnapshots(psdp, writer, numSnapshots, "snapshot");
     writer.close();
     dir.close();
Index: lucene/core/src/test/org/apache/lucene/index/TestConcurrentMergeScheduler.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestConcurrentMergeScheduler.java	(révision 1461535)
+++ lucene/core/src/test/org/apache/lucene/index/TestConcurrentMergeScheduler.java	(copie de travail)
@@ -365,7 +365,7 @@
         w.deleteDocuments(new Term("id", ""+random().nextInt(i+1)));
       }
     }
-    assertTrue(((TrackingCMS) iwc.getMergeScheduler()).totMergedBytes != 0);
+    assertTrue(((TrackingCMS) w.w.getConfig().getMergeScheduler()).totMergedBytes != 0);
     w.close();
     d.close();
   }
Index: lucene/core/src/test/org/apache/lucene/index/TestDirectoryReaderReopen.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestDirectoryReaderReopen.java	(révision 1461535)
+++ lucene/core/src/test/org/apache/lucene/index/TestDirectoryReaderReopen.java	(copie de travail)
@@ -530,7 +530,7 @@
     protected abstract void modifyIndex(int i) throws IOException;
   }
   
-  static class KeepAllCommits implements IndexDeletionPolicy {
+  static class KeepAllCommits extends IndexDeletionPolicy {
     @Override
     public void onInit(List<? extends IndexCommit> commits) {
     }
Index: lucene/core/src/test/org/apache/lucene/index/TestDeletionPolicy.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestDeletionPolicy.java	(révision 1461535)
+++ lucene/core/src/test/org/apache/lucene/index/TestDeletionPolicy.java	(copie de travail)
@@ -57,10 +57,15 @@
     }
   }
 
-  class KeepAllDeletionPolicy implements IndexDeletionPolicy {
+  class KeepAllDeletionPolicy extends IndexDeletionPolicy {
     int numOnInit;
     int numOnCommit;
     Directory dir;
+
+    KeepAllDeletionPolicy(Directory dir) {
+      this.dir = dir;
+    }
+
     @Override
     public void onInit(List<? extends IndexCommit> commits) throws IOException {
       verifyCommitOrder(commits);
@@ -75,13 +80,14 @@
       verifyCommitOrder(commits);
       numOnCommit++;
     }
+
   }
 
   /**
    * This is useful for adding to a big index when you know
    * readers are not using it.
    */
-  class KeepNoneOnInitDeletionPolicy implements IndexDeletionPolicy {
+  class KeepNoneOnInitDeletionPolicy extends IndexDeletionPolicy {
     int numOnInit;
     int numOnCommit;
     @Override
@@ -106,7 +112,7 @@
     }
   }
 
-  class KeepLastNDeletionPolicy implements IndexDeletionPolicy {
+  class KeepLastNDeletionPolicy extends IndexDeletionPolicy {
     int numOnInit;
     int numOnCommit;
     int numToKeep;
@@ -165,7 +171,7 @@
    * Delete a commit only when it has been obsoleted by N
    * seconds.
    */
-  class ExpirationTimeDeletionPolicy implements IndexDeletionPolicy {
+  class ExpirationTimeDeletionPolicy extends IndexDeletionPolicy {
 
     Directory dir;
     double expirationTimeSeconds;
@@ -209,15 +215,15 @@
     final double SECONDS = 2.0;
 
     Directory dir = newDirectory();
-    ExpirationTimeDeletionPolicy policy = new ExpirationTimeDeletionPolicy(dir, SECONDS);
     IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT,
         new MockAnalyzer(random()))
-        .setIndexDeletionPolicy(policy);
+        .setIndexDeletionPolicy(new ExpirationTimeDeletionPolicy(dir, SECONDS));
     MergePolicy mp = conf.getMergePolicy();
     if (mp instanceof LogMergePolicy) {
       ((LogMergePolicy) mp).setUseCompoundFile(true);
     }
     IndexWriter writer = new IndexWriter(dir, conf);
+    ExpirationTimeDeletionPolicy policy = (ExpirationTimeDeletionPolicy) writer.getConfig().getIndexDeletionPolicy();
     Map<String,String> commitData = new HashMap<String,String>();
     commitData.put("commitTime", String.valueOf(System.currentTimeMillis()));
     writer.setCommitData(commitData);
@@ -238,6 +244,7 @@
         ((LogMergePolicy) mp).setUseCompoundFile(true);
       }
       writer = new IndexWriter(dir, conf);
+      policy = (ExpirationTimeDeletionPolicy) writer.getConfig().getIndexDeletionPolicy();
       for(int j=0;j<17;j++) {
         addDoc(writer);
       }
@@ -305,21 +312,19 @@
 
       boolean useCompoundFile = (pass % 2) != 0;
 
-      // Never deletes a commit
-      KeepAllDeletionPolicy policy = new KeepAllDeletionPolicy();
-
       Directory dir = newDirectory();
-      policy.dir = dir;
 
       IndexWriterConfig conf = newIndexWriterConfig(
           TEST_VERSION_CURRENT, new MockAnalyzer(random()))
-          .setIndexDeletionPolicy(policy).setMaxBufferedDocs(10)
+          .setIndexDeletionPolicy(new KeepAllDeletionPolicy(dir))
+          .setMaxBufferedDocs(10)
           .setMergeScheduler(new SerialMergeScheduler());
       MergePolicy mp = conf.getMergePolicy();
       if (mp instanceof LogMergePolicy) {
         ((LogMergePolicy) mp).setUseCompoundFile(useCompoundFile);
       }
       IndexWriter writer = new IndexWriter(dir, conf);
+      KeepAllDeletionPolicy policy = (KeepAllDeletionPolicy) writer.getConfig().getIndexDeletionPolicy();
       for(int i=0;i<107;i++) {
         addDoc(writer);
       }
@@ -343,9 +348,11 @@
           System.out.println("TEST: open writer for forceMerge");
         }
         writer = new IndexWriter(dir, conf);
+        policy = (KeepAllDeletionPolicy) writer.getConfig().getIndexDeletionPolicy();
         writer.forceMerge(1);
         writer.close();
       }
+
       assertEquals(needsMerging ? 1:0, policy.numOnInit);
 
       // If we are not auto committing then there should
@@ -397,19 +404,16 @@
    * then, opens a new IndexWriter on a previous commit
    * point. */
   public void testOpenPriorSnapshot() throws IOException {
-    // Never deletes a commit
-    KeepAllDeletionPolicy policy = new KeepAllDeletionPolicy();
-
     Directory dir = newDirectory();
-    policy.dir = dir;
 
     IndexWriter writer = new IndexWriter(
         dir,
         newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).
-            setIndexDeletionPolicy(policy).
+            setIndexDeletionPolicy(new KeepAllDeletionPolicy(dir)).
             setMaxBufferedDocs(2).
             setMergePolicy(newLogMergePolicy(10))
     );
+    KeepAllDeletionPolicy policy = (KeepAllDeletionPolicy) writer.getConfig().getIndexDeletionPolicy();
     for(int i=0;i<10;i++) {
       addDoc(writer);
       if ((1+i)%2 == 0)
@@ -508,19 +512,19 @@
 
       boolean useCompoundFile = (pass % 2) != 0;
 
-      KeepNoneOnInitDeletionPolicy policy = new KeepNoneOnInitDeletionPolicy();
-
       Directory dir = newDirectory();
 
       IndexWriterConfig conf = newIndexWriterConfig(
           TEST_VERSION_CURRENT, new MockAnalyzer(random()))
-          .setOpenMode(OpenMode.CREATE).setIndexDeletionPolicy(policy)
+          .setOpenMode(OpenMode.CREATE)
+          .setIndexDeletionPolicy(new KeepNoneOnInitDeletionPolicy())
           .setMaxBufferedDocs(10);
       MergePolicy mp = conf.getMergePolicy();
       if (mp instanceof LogMergePolicy) {
         ((LogMergePolicy) mp).setUseCompoundFile(useCompoundFile);
       }
       IndexWriter writer = new IndexWriter(dir, conf);
+      KeepNoneOnInitDeletionPolicy policy = (KeepNoneOnInitDeletionPolicy) writer.getConfig().getIndexDeletionPolicy();
       for(int i=0;i<107;i++) {
         addDoc(writer);
       }
@@ -533,6 +537,7 @@
         ((LogMergePolicy) mp).setUseCompoundFile(true);
       }
       writer = new IndexWriter(dir, conf);
+      policy = (KeepNoneOnInitDeletionPolicy) writer.getConfig().getIndexDeletionPolicy();
       writer.forceMerge(1);
       writer.close();
 
@@ -563,17 +568,18 @@
       Directory dir = newDirectory();
 
       KeepLastNDeletionPolicy policy = new KeepLastNDeletionPolicy(N);
-
       for(int j=0;j<N+1;j++) {
         IndexWriterConfig conf = newIndexWriterConfig(
             TEST_VERSION_CURRENT, new MockAnalyzer(random()))
-            .setOpenMode(OpenMode.CREATE).setIndexDeletionPolicy(policy)
+            .setOpenMode(OpenMode.CREATE)
+            .setIndexDeletionPolicy(policy)
             .setMaxBufferedDocs(10);
         MergePolicy mp = conf.getMergePolicy();
         if (mp instanceof LogMergePolicy) {
           ((LogMergePolicy) mp).setUseCompoundFile(useCompoundFile);
         }
         IndexWriter writer = new IndexWriter(dir, conf);
+        policy = (KeepLastNDeletionPolicy) writer.getConfig().getIndexDeletionPolicy();
         for(int i=0;i<17;i++) {
           addDoc(writer);
         }
@@ -623,18 +629,18 @@
 
       boolean useCompoundFile = (pass % 2) != 0;
 
-      KeepLastNDeletionPolicy policy = new KeepLastNDeletionPolicy(N);
-
       Directory dir = newDirectory();
       IndexWriterConfig conf = newIndexWriterConfig(
           TEST_VERSION_CURRENT, new MockAnalyzer(random()))
-          .setOpenMode(OpenMode.CREATE).setIndexDeletionPolicy(policy)
+          .setOpenMode(OpenMode.CREATE)
+          .setIndexDeletionPolicy(new KeepLastNDeletionPolicy(N))
           .setMaxBufferedDocs(10);
       MergePolicy mp = conf.getMergePolicy();
       if (mp instanceof LogMergePolicy) {
         ((LogMergePolicy) mp).setUseCompoundFile(useCompoundFile);
       }
       IndexWriter writer = new IndexWriter(dir, conf);
+      KeepLastNDeletionPolicy policy = (KeepLastNDeletionPolicy) writer.getConfig().getIndexDeletionPolicy();
       writer.close();
       Term searchTerm = new Term("content", "aaa");        
       Query query = new TermQuery(searchTerm);
@@ -650,6 +656,7 @@
           ((LogMergePolicy) mp).setUseCompoundFile(useCompoundFile);
         }
         writer = new IndexWriter(dir, conf);
+        policy = (KeepLastNDeletionPolicy) writer.getConfig().getIndexDeletionPolicy();
         for(int j=0;j<17;j++) {
           addDocWithID(writer, i*(N+1)+j);
         }
@@ -659,6 +666,7 @@
           .setIndexDeletionPolicy(policy)
           .setMergePolicy(NoMergePolicy.COMPOUND_FILES);
         writer = new IndexWriter(dir, conf);
+        policy = (KeepLastNDeletionPolicy) writer.getConfig().getIndexDeletionPolicy();
         writer.deleteDocuments(new Term("id", "" + (i*(N+1)+3)));
         // this is a commit
         writer.close();
@@ -671,6 +679,7 @@
         writer = new IndexWriter(dir, newIndexWriterConfig(
             TEST_VERSION_CURRENT, new MockAnalyzer(random()))
             .setOpenMode(OpenMode.CREATE).setIndexDeletionPolicy(policy));
+        policy = (KeepLastNDeletionPolicy) writer.getConfig().getIndexDeletionPolicy();
         // This will not commit: there are no changes
         // pending because we opened for "create":
         writer.close();
Index: lucene/core/src/test/org/apache/lucene/index/TestSnapshotDeletionPolicy.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestSnapshotDeletionPolicy.java	(révision 1461535)
+++ lucene/core/src/test/org/apache/lucene/index/TestSnapshotDeletionPolicy.java	(copie de travail)
@@ -101,10 +101,10 @@
     // Run for ~1 seconds
     final long stopTime = System.currentTimeMillis() + 1000;
 
-    SnapshotDeletionPolicy dp = getDeletionPolicy();
     final IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
-        TEST_VERSION_CURRENT, new MockAnalyzer(random)).setIndexDeletionPolicy(dp)
+        TEST_VERSION_CURRENT, new MockAnalyzer(random)).setIndexDeletionPolicy(getDeletionPolicy())
         .setMaxBufferedDocs(2));
+    SnapshotDeletionPolicy dp = (SnapshotDeletionPolicy) writer.getConfig().getIndexDeletionPolicy();
     writer.commit();
     
     final Thread t = new Thread() {
@@ -235,11 +235,11 @@
   @Test
   public void testBasicSnapshots() throws Exception {
     int numSnapshots = 3;
-    SnapshotDeletionPolicy sdp = getDeletionPolicy();
     
     // Create 3 snapshots: snapshot0, snapshot1, snapshot2
     Directory dir = newDirectory();
-    IndexWriter writer = new IndexWriter(dir, getConfig(random(), sdp));
+    IndexWriter writer = new IndexWriter(dir, getConfig(random(), getDeletionPolicy()));
+    SnapshotDeletionPolicy sdp = (SnapshotDeletionPolicy) writer.getConfig().getIndexDeletionPolicy();
     prepareIndexAndSnapshots(sdp, writer, numSnapshots, "snapshot");
     writer.close();
     
@@ -269,8 +269,8 @@
   @Test
   public void testMultiThreadedSnapshotting() throws Exception {
     Directory dir = newDirectory();
-    final SnapshotDeletionPolicy sdp = getDeletionPolicy();
-    final IndexWriter writer = new IndexWriter(dir, getConfig(random(), sdp));
+    final IndexWriter writer = new IndexWriter(dir, getConfig(random(), getDeletionPolicy()));
+    final SnapshotDeletionPolicy sdp = (SnapshotDeletionPolicy) writer.getConfig().getIndexDeletionPolicy();
 
     Thread[] threads = new Thread[10];
     for (int i = 0; i < threads.length; i++) {
@@ -315,8 +315,8 @@
     int numSnapshots = 2;
     Directory dir = newDirectory();
 
-    SnapshotDeletionPolicy sdp = getDeletionPolicy();
-    IndexWriter writer = new IndexWriter(dir, getConfig(random(), sdp));
+    IndexWriter writer = new IndexWriter(dir, getConfig(random(), getDeletionPolicy()));
+    SnapshotDeletionPolicy sdp = (SnapshotDeletionPolicy) writer.getConfig().getIndexDeletionPolicy();
     prepareIndexAndSnapshots(sdp, writer, numSnapshots, "snapshot");
     writer.close();
 
@@ -338,8 +338,8 @@
   @Test
   public void testReleaseSnapshot() throws Exception {
     Directory dir = newDirectory();
-    SnapshotDeletionPolicy sdp = getDeletionPolicy();
-    IndexWriter writer = new IndexWriter(dir, getConfig(random(), sdp));
+    IndexWriter writer = new IndexWriter(dir, getConfig(random(), getDeletionPolicy()));
+    SnapshotDeletionPolicy sdp = (SnapshotDeletionPolicy) writer.getConfig().getIndexDeletionPolicy();
     prepareIndexAndSnapshots(sdp, writer, 1, "snapshot");
     
     // Create another commit - we must do that, because otherwise the "snapshot"
@@ -370,8 +370,8 @@
     // asserts that those snapshots/commit points are protected.
     int numSnapshots = 3;
     Directory dir = newDirectory();
-    SnapshotDeletionPolicy sdp = getDeletionPolicy();
-    IndexWriter writer = new IndexWriter(dir, getConfig(random(), sdp));
+    IndexWriter writer = new IndexWriter(dir, getConfig(random(), getDeletionPolicy()));
+    SnapshotDeletionPolicy sdp = (SnapshotDeletionPolicy) writer.getConfig().getIndexDeletionPolicy();
     prepareIndexAndSnapshots(sdp, writer, numSnapshots, "snapshot");
     writer.close();
 
@@ -389,8 +389,8 @@
   public void testSnapshotLastCommitTwice() throws Exception {
     Directory dir = newDirectory();
 
-    SnapshotDeletionPolicy sdp = getDeletionPolicy();
-    IndexWriter writer = new IndexWriter(dir, getConfig(random(), sdp));
+    IndexWriter writer = new IndexWriter(dir, getConfig(random(), getDeletionPolicy()));
+    SnapshotDeletionPolicy sdp = (SnapshotDeletionPolicy) writer.getConfig().getIndexDeletionPolicy();
     writer.addDocument(new Document());
     writer.commit();
     
@@ -418,8 +418,8 @@
     // Tests the behavior of SDP when commits that are given at ctor are missing
     // on onInit().
     Directory dir = newDirectory();
-    SnapshotDeletionPolicy sdp = getDeletionPolicy();
-    IndexWriter writer = new IndexWriter(dir, getConfig(random(), sdp));
+    IndexWriter writer = new IndexWriter(dir, getConfig(random(), getDeletionPolicy()));
+    SnapshotDeletionPolicy sdp = (SnapshotDeletionPolicy) writer.getConfig().getIndexDeletionPolicy();
     writer.addDocument(new Document());
     writer.commit();
     IndexCommit ic = sdp.snapshot("s1");
@@ -436,8 +436,9 @@
     
     // Now reinit SDP from the commits in the index - the snapshot id should not
     // exist anymore.
-    sdp = getDeletionPolicy(sdp.getSnapshots());
-    new IndexWriter(dir, getConfig(random(), sdp)).close();
+    writer = new IndexWriter(dir, getConfig(random(), getDeletionPolicy(sdp.getSnapshots())));
+    sdp = (SnapshotDeletionPolicy) writer.getConfig().getIndexDeletionPolicy();
+    writer.close();
     
     try {
       sdp.getSnapshot("s1");
Index: lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java	(révision 1461535)
+++ lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java	(copie de travail)
@@ -1371,10 +1371,10 @@
     // Validates that iw.deleteUnusedFiles() also deletes unused index commits
     // in case a deletion policy which holds onto commits is used.
     Directory dir = newDirectory();
-    SnapshotDeletionPolicy sdp = new SnapshotDeletionPolicy(new KeepOnlyLastCommitDeletionPolicy());
     IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
         TEST_VERSION_CURRENT, new MockAnalyzer(random()))
-        .setIndexDeletionPolicy(sdp));
+        .setIndexDeletionPolicy(new SnapshotDeletionPolicy(new KeepOnlyLastCommitDeletionPolicy())));
+    SnapshotDeletionPolicy sdp = (SnapshotDeletionPolicy) writer.getConfig().getIndexDeletionPolicy();
 
     // First commit
     Document doc = new Document();
Index: lucene/core/src/test/org/apache/lucene/index/TestIndexWriterConfig.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestIndexWriterConfig.java	(révision 1461535)
+++ lucene/core/src/test/org/apache/lucene/index/TestIndexWriterConfig.java	(copie de travail)
@@ -216,9 +216,27 @@
     IndexWriterConfig conf = new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
     IndexWriterConfig clone = conf.clone();
 
-    // Clone is shallow since not all parameters are cloneable.
-    assertTrue(conf.getIndexDeletionPolicy() == clone.getIndexDeletionPolicy());
+    // Make sure parameters that can't be reused are cloned
+    IndexDeletionPolicy delPolicy = conf.delPolicy;
+    IndexDeletionPolicy delPolicyClone = clone.delPolicy;
+    assertTrue(delPolicy.getClass() == delPolicyClone.getClass() && (delPolicy != delPolicyClone || delPolicy.clone() == delPolicyClone.clone()));
 
+    FlushPolicy flushPolicy = conf.flushPolicy;
+    FlushPolicy flushPolicyClone = clone.flushPolicy;
+    assertTrue(flushPolicy.getClass() == flushPolicyClone.getClass() && (flushPolicy != flushPolicyClone || flushPolicy.clone() == flushPolicyClone.clone()));
+
+    DocumentsWriterPerThreadPool pool = conf.indexerThreadPool;
+    DocumentsWriterPerThreadPool poolClone = clone.indexerThreadPool;
+    assertTrue(pool.getClass() == poolClone.getClass() && (pool != poolClone || pool.clone() == poolClone.clone()));
+
+    MergePolicy mergePolicy = conf.mergePolicy;
+    MergePolicy mergePolicyClone = clone.mergePolicy;
+    assertTrue(mergePolicy.getClass() == mergePolicyClone.getClass() && (mergePolicy != mergePolicyClone || mergePolicy.clone() == mergePolicyClone.clone()));
+
+    MergeScheduler mergeSched = conf.mergeScheduler;
+    MergeScheduler mergeSchedClone = clone.mergeScheduler;
+    assertTrue(mergeSched.getClass() == mergeSchedClone.getClass() && (mergeSched != mergeSchedClone || mergeSched.clone() == mergeSchedClone.clone()));
+
     conf.setMergeScheduler(new SerialMergeScheduler());
     assertEquals(ConcurrentMergeScheduler.class, clone.getMergeScheduler().getClass());
   }
Index: lucene/core/src/test/org/apache/lucene/index/TestDirectoryReader.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestDirectoryReader.java	(révision 1461535)
+++ lucene/core/src/test/org/apache/lucene/index/TestDirectoryReader.java	(copie de travail)
@@ -893,9 +893,9 @@
   // LUCENE-2753
   public void testListCommits() throws Exception {
     Directory dir = newDirectory();
-    SnapshotDeletionPolicy sdp = new SnapshotDeletionPolicy(new KeepOnlyLastCommitDeletionPolicy());
-    IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig( 
-        TEST_VERSION_CURRENT, null).setIndexDeletionPolicy(sdp));
+    IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, null)
+        .setIndexDeletionPolicy(new SnapshotDeletionPolicy(new KeepOnlyLastCommitDeletionPolicy())));
+    SnapshotDeletionPolicy sdp = (SnapshotDeletionPolicy) writer.getConfig().getIndexDeletionPolicy();
     writer.addDocument(new Document());
     writer.commit();
     sdp.snapshot("c1");
Index: lucene/core/src/test/org/apache/lucene/index/TestTransactionRollback.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestTransactionRollback.java	(révision 1461535)
+++ lucene/core/src/test/org/apache/lucene/index/TestTransactionRollback.java	(copie de travail)
@@ -156,7 +156,7 @@
   }
 
   // Rolls back to previous commit point
-  class RollbackDeletionPolicy implements IndexDeletionPolicy {
+  class RollbackDeletionPolicy extends IndexDeletionPolicy {
     private int rollbackPoint;
 
     public RollbackDeletionPolicy(int rollbackPoint) {
@@ -196,7 +196,7 @@
     }
   }
 
-  class DeleteLastCommitPolicy implements IndexDeletionPolicy {
+  class DeleteLastCommitPolicy extends IndexDeletionPolicy {
 
     @Override
     public void onCommit(List<? extends IndexCommit> commits) throws IOException {}
@@ -221,7 +221,7 @@
   }
 
   // Keeps all commit points (used to build index)
-  class KeepAllDeletionPolicy implements IndexDeletionPolicy {
+  class KeepAllDeletionPolicy extends IndexDeletionPolicy {
     @Override
     public void onCommit(List<? extends IndexCommit> commits) throws IOException {}
     @Override
Index: lucene/core/src/java/org/apache/lucene/index/IndexWriterConfig.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/index/IndexWriterConfig.java	(révision 1461535)
+++ lucene/core/src/java/org/apache/lucene/index/IndexWriterConfig.java	(copie de travail)
@@ -151,9 +151,14 @@
       // Mostly shallow clone, but do a deepish clone of
       // certain objects that have state that cannot be shared
       // across IW instances:
+      clone.delPolicy = delPolicy.clone();
       clone.flushPolicy = flushPolicy.clone();
       clone.indexerThreadPool = indexerThreadPool.clone();
+      // we clone the infoStream because some impls might have state variables
+      // such as line numbers, message throughput, ...
+      clone.infoStream = infoStream.clone();
       clone.mergePolicy = mergePolicy.clone();
+      clone.mergeScheduler = mergeScheduler.clone();
       
       return clone;
     } catch (CloneNotSupportedException e) {
Index: lucene/core/src/java/org/apache/lucene/index/IndexDeletionPolicy.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/index/IndexDeletionPolicy.java	(révision 1461535)
+++ lucene/core/src/java/org/apache/lucene/index/IndexDeletionPolicy.java	(copie de travail)
@@ -48,7 +48,7 @@
  * for details.</p>
  */
 
-public interface IndexDeletionPolicy {
+public abstract class IndexDeletionPolicy implements Cloneable {
 
   /**
    * <p>This is called once when a writer is first
@@ -70,7 +70,7 @@
    * {@link IndexCommit point-in-time commits},
    *  sorted by age (the 0th one is the oldest commit).
    */
-  public void onInit(List<? extends IndexCommit> commits) throws IOException;
+  public abstract void onInit(List<? extends IndexCommit> commits) throws IOException;
 
   /**
    * <p>This is called each time the writer completed a commit.
@@ -94,5 +94,15 @@
    * @param commits List of {@link IndexCommit},
    *  sorted by age (the 0th one is the oldest commit).
    */
-  public void onCommit(List<? extends IndexCommit> commits) throws IOException;
+  public abstract void onCommit(List<? extends IndexCommit> commits) throws IOException;
+
+  @Override
+  public IndexDeletionPolicy clone() {
+    try {
+      return (IndexDeletionPolicy) super.clone();
+    } catch (CloneNotSupportedException e) {
+      throw new Error(e);
+    }
+  }
+
 }
Index: lucene/core/src/java/org/apache/lucene/index/KeepOnlyLastCommitDeletionPolicy.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/index/KeepOnlyLastCommitDeletionPolicy.java	(révision 1461535)
+++ lucene/core/src/java/org/apache/lucene/index/KeepOnlyLastCommitDeletionPolicy.java	(copie de travail)
@@ -26,7 +26,7 @@
  * the default deletion policy.
  */
 
-public final class KeepOnlyLastCommitDeletionPolicy implements IndexDeletionPolicy {
+public final class KeepOnlyLastCommitDeletionPolicy extends IndexDeletionPolicy {
 
   /** Sole constructor. */
   public KeepOnlyLastCommitDeletionPolicy() {
Index: lucene/core/src/java/org/apache/lucene/index/ConcurrentMergeScheduler.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/index/ConcurrentMergeScheduler.java	(révision 1461535)
+++ lucene/core/src/java/org/apache/lucene/index/ConcurrentMergeScheduler.java	(copie de travail)
@@ -561,4 +561,13 @@
     sb.append("mergeThreadPriority=").append(mergeThreadPriority);
     return sb.toString();
   }
+
+  @Override
+  public MergeScheduler clone() {
+    ConcurrentMergeScheduler clone = (ConcurrentMergeScheduler) super.clone();
+    clone.writer = null;
+    clone.dir = null;
+    clone.mergeThreads = new ArrayList<MergeThread>();
+    return clone;
+  }
 }
Index: lucene/core/src/java/org/apache/lucene/index/SnapshotDeletionPolicy.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/index/SnapshotDeletionPolicy.java	(révision 1461535)
+++ lucene/core/src/java/org/apache/lucene/index/SnapshotDeletionPolicy.java	(copie de travail)
@@ -49,7 +49,7 @@
  * 
  * @lucene.experimental
  */
-public class SnapshotDeletionPolicy implements IndexDeletionPolicy {
+public class SnapshotDeletionPolicy extends IndexDeletionPolicy {
 
   /** Holds a Snapshot's information. */
   private static class SnapshotInfo {
@@ -373,4 +373,14 @@
     return lastCommit;
   }
 
+  @Override
+  public IndexDeletionPolicy clone() {
+    SnapshotDeletionPolicy other = (SnapshotDeletionPolicy) super.clone();
+    other.primary = this.primary.clone();
+    other.lastCommit = null;
+    other.segmentsFileToIDs = new HashMap<String, Set<String>>(segmentsFileToIDs);
+    other.idToSnapshot = new HashMap<String, SnapshotInfo>(idToSnapshot);
+    return other;
+  }
+
 }
Index: lucene/core/src/java/org/apache/lucene/index/NoDeletionPolicy.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/index/NoDeletionPolicy.java	(révision 1461535)
+++ lucene/core/src/java/org/apache/lucene/index/NoDeletionPolicy.java	(copie de travail)
@@ -24,7 +24,7 @@
  * deleting them. This class is a singleton and can be accessed by referencing
  * {@link #INSTANCE}.
  */
-public final class NoDeletionPolicy implements IndexDeletionPolicy {
+public final class NoDeletionPolicy extends IndexDeletionPolicy {
 
   /** The single instance of this class. */
   public static final IndexDeletionPolicy INSTANCE = new NoDeletionPolicy();
@@ -38,5 +38,10 @@
 
   @Override
   public void onInit(List<? extends IndexCommit> commits) {}
-  
+
+  @Override
+  public IndexDeletionPolicy clone() {
+    return this;
+  }
+
 }
Index: lucene/core/src/java/org/apache/lucene/index/NoMergeScheduler.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/index/NoMergeScheduler.java	(révision 1461535)
+++ lucene/core/src/java/org/apache/lucene/index/NoMergeScheduler.java	(copie de travail)
@@ -41,4 +41,10 @@
 
   @Override
   public void merge(IndexWriter writer) {}
+
+  @Override
+  public MergeScheduler clone() {
+    return this;
+  }
+
 }
Index: lucene/core/src/java/org/apache/lucene/index/MergeScheduler.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/index/MergeScheduler.java	(révision 1461535)
+++ lucene/core/src/java/org/apache/lucene/index/MergeScheduler.java	(copie de travail)
@@ -27,7 +27,7 @@
  *
  * @lucene.experimental
 */
-public abstract class MergeScheduler implements Closeable {
+public abstract class MergeScheduler implements Closeable, Cloneable {
 
   /** Sole constructor. (For invocation by subclass 
    *  constructors, typically implicit.) */
@@ -40,4 +40,13 @@
   /** Close this MergeScheduler. */
   @Override
   public abstract void close() throws IOException;
+
+  @Override
+  public MergeScheduler clone() {
+    try {
+      return (MergeScheduler) super.clone();
+    } catch (CloneNotSupportedException e) {
+      throw new Error(e);
+    }
+  }
 }
Index: lucene/core/src/java/org/apache/lucene/util/InfoStream.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/util/InfoStream.java	(révision 1461535)
+++ lucene/core/src/java/org/apache/lucene/util/InfoStream.java	(copie de travail)
@@ -30,7 +30,7 @@
  * 
  * @lucene.internal 
  */
-public abstract class InfoStream implements Closeable {
+public abstract class InfoStream implements Closeable, Cloneable {
 
   /** Instance of InfoStream that does no logging at all. */
   public static final InfoStream NO_OUTPUT = new NoOutput();
@@ -74,5 +74,14 @@
     }
     defaultInfoStream = infoStream;
   }
-  
+
+  @Override
+  public InfoStream clone() {
+    try {
+      return (InfoStream) super.clone();
+    } catch (CloneNotSupportedException e) {
+      throw new Error(e);
+    }
+  }
+
 }
