Index: lucene/src/java/org/apache/lucene/index/codecs/Codec.java
===================================================================
--- lucene/src/java/org/apache/lucene/index/codecs/Codec.java	(revision 1162486)
+++ lucene/src/java/org/apache/lucene/index/codecs/Codec.java	(working copy)
@@ -34,12 +34,22 @@
   /** Unique name that's used to retrieve this codec when
    *  reading the index */
   public final String name;
-  private boolean dvUseCompoundFile = true;
-  private Comparator<BytesRef> docValuesSortComparator = BytesRef
-      .getUTF8SortedAsUnicodeComparator();
+  protected final boolean dvUseCompoundFile;
+  protected final Comparator<BytesRef> docValuesSortComparator;
   
   protected Codec(String name) {
+    this(name, true);
+  }
+  
+  protected Codec(String name, boolean docValuesUseCompoundFile) {
+    this(name, docValuesUseCompoundFile, BytesRef.getUTF8SortedAsUnicodeComparator());
+  }
+
+  protected Codec(String name, boolean docValuesUseCompoundFile,
+      Comparator<BytesRef> docValuesSortComparator) {
     this.name = name;
+    this.dvUseCompoundFile = docValuesUseCompoundFile;
+    this.docValuesSortComparator = docValuesSortComparator;
   }
 
   /** Writes a new segment */
@@ -77,43 +87,34 @@
 
   /** Records all file extensions this codec uses */
   public abstract void getExtensions(Set<String> extensions);
-  
 
   /**
-   * If set to <code>true</code> this codec will use a compound file for
-   * IndexDocValues, otherwise each IndexDocValues field will create up to 2
-   * files per segment.
+   * Returns <code>true</code> iff compound file should be used for
+   * IndexDocValues, otherwise <code>false</code>. The default is
+   * <code>true</code>.
    * <p>
-   * NOTE: The default values is <code>true</code>.
-   */
-  public void setDocValuesUseCFS(boolean docValuesUseCFS) {
-    this.dvUseCompoundFile = docValuesUseCFS;
-  }
-
-  /**
-   * Returns <code>true</code> iff compound file should be used for
-   * IndexDocValues, otherwise <code>false</code>.
+   * NOTE: To change the default value you need to subclass a {@link Codec} with
+   * a distinct name since this value is final and should not be changed to
+   * prevent the risk of a index corruption. This setting is private to a
+   * {@link Codec}. If you intend to change this value on an existing
+   * {@link Codec} re-indexing is required.
    * 
-   * @see #setDocValuesUseCFS(boolean)
    * @return <code>true</code> iff compound file should be used for
    *         IndexDocValues, otherwise <code>false</code>.
    */
   public boolean getDocValuesUseCFS() {
     return dvUseCompoundFile;
   }
-  
-  /**
-   * Sets the {@link BytesRef} comparator for sorted IndexDocValue variants. The
-   * default is {@link BytesRef#getUTF8SortedAsUnicodeComparator()}. *
-   */
-  public void setDocValuesSortComparator(
-      Comparator<BytesRef> docValuesSortComparator) {
-    this.docValuesSortComparator = docValuesSortComparator;
-  }
 
   /**
    * Returns the {@link BytesRef} comparator for sorted IndexDocValue variants.
    * The default is {@link BytesRef#getUTF8SortedAsUnicodeComparator()}.
+   * <p>
+   * NOTE: To change the default value you need to subclass a {@link Codec} with
+   * a distinct name since this value is final and should not be changed to
+   * prevent the risk of a index corruption. This setting is private to a
+   * {@link Codec}. If you intend to change this value on an existing
+   * {@link Codec} re-indexing is required.
    */
   public Comparator<BytesRef> getDocValuesSortComparator() {
     return docValuesSortComparator;
Index: lucene/src/test-framework/org/apache/lucene/index/RandomCodecProvider.java
===================================================================
--- lucene/src/test-framework/org/apache/lucene/index/RandomCodecProvider.java	(revision 1162486)
+++ lucene/src/test-framework/org/apache/lucene/index/RandomCodecProvider.java	(working copy)
@@ -54,15 +54,15 @@
     // block via CL:
     int minItemsPerBlock = _TestUtil.nextInt(random, 2, 100);
     int maxItemsPerBlock = 2*(Math.max(2, minItemsPerBlock-1)) + random.nextInt(100);
-    register(_TestUtil.randomizeCodec(random, new StandardCodec(minItemsPerBlock, maxItemsPerBlock)));
-    register(_TestUtil.randomizeCodec(random, new PreFlexCodec()));
+    register(new StandardCodec(minItemsPerBlock, maxItemsPerBlock));
+    register(new PreFlexCodec());
     // TODO: make it possible to specify min/max iterms per
     // block via CL:
     minItemsPerBlock = _TestUtil.nextInt(random, 2, 100);
     maxItemsPerBlock = 2*(Math.max(1, minItemsPerBlock-1)) + random.nextInt(100);
-    register(_TestUtil.randomizeCodec(random, new PulsingCodec( 1 + random.nextInt(20), minItemsPerBlock, maxItemsPerBlock)));
-    register(_TestUtil.randomizeCodec(random, new SimpleTextCodec()));
-    register(_TestUtil.randomizeCodec(random, new MemoryCodec()));
+    register(new PulsingCodec( 1 + random.nextInt(20), minItemsPerBlock, maxItemsPerBlock));
+    register(new SimpleTextCodec());
+    register(new MemoryCodec());
     Collections.shuffle(knownCodecs, random);
   }
   
Index: lucene/src/test-framework/org/apache/lucene/index/codecs/mockrandom/MockRandomCodec.java
===================================================================
--- lucene/src/test-framework/org/apache/lucene/index/codecs/mockrandom/MockRandomCodec.java	(revision 1162486)
+++ lucene/src/test-framework/org/apache/lucene/index/codecs/mockrandom/MockRandomCodec.java	(working copy)
@@ -80,7 +80,12 @@
   private final String SEED_EXT = "sd";
   
   public MockRandomCodec(Random random) {
-    super("MockRandom");
+    this(random, "MockRandom", true);
+    
+  }
+  
+  protected MockRandomCodec(Random random, String name, boolean docValuesUseCompoundFile) {
+    super(name, docValuesUseCompoundFile);
     this.seedRandom = new Random(random.nextLong());
   }
 
Index: lucene/src/test-framework/org/apache/lucene/util/LuceneTestCase.java
===================================================================
--- lucene/src/test-framework/org/apache/lucene/util/LuceneTestCase.java	(revision 1162486)
+++ lucene/src/test-framework/org/apache/lucene/util/LuceneTestCase.java	(working copy)
@@ -43,6 +43,7 @@
 import org.apache.lucene.index.codecs.mockintblock.MockVariableIntBlockCodec;
 import org.apache.lucene.index.codecs.mocksep.MockSepCodec;
 import org.apache.lucene.index.codecs.mockrandom.MockRandomCodec;
+import org.apache.lucene.index.codecs.mockrandom.MockRandomDocValuesCodec;
 import org.apache.lucene.index.codecs.preflex.PreFlexCodec;
 import org.apache.lucene.index.codecs.preflexrw.PreFlexRWCodec;
 import org.apache.lucene.index.codecs.pulsing.PulsingCodec;
@@ -227,7 +228,7 @@
     if (prior != null) {
       cp.unregister(prior);
     }
-    cp.register(_TestUtil.randomizeCodec(random, c));
+    cp.register(c);
   }
 
   // returns current default codec
@@ -274,6 +275,8 @@
     // baseBlockSize cannot be over 127:
     swapCodec(new MockVariableIntBlockCodec(codecHasParam && "MockVariableIntBlock".equals(codec) ? codecParam : _TestUtil.nextInt(random, 1, 127)), cp);
     swapCodec(new MockRandomCodec(random), cp);
+    // give docvalues non-cfs testcoverage
+    swapCodec(new MockRandomDocValuesCodec(random), cp);
 
     return cp.lookup(codec);
   }
Index: lucene/src/test-framework/org/apache/lucene/util/_TestUtil.java
===================================================================
--- lucene/src/test-framework/org/apache/lucene/util/_TestUtil.java	(revision 1162486)
+++ lucene/src/test-framework/org/apache/lucene/util/_TestUtil.java	(working copy)
@@ -514,9 +514,4 @@
 
     return doc2;
   }
-  
-  public static Codec randomizeCodec(Random random, Codec codec) {
-    codec.setDocValuesUseCFS(random.nextBoolean());
-    return codec;
-  }
 }
