Index: lucene/src/java/org/apache/lucene/store/CompoundFileDirectory.java
===================================================================
--- lucene/src/java/org/apache/lucene/store/CompoundFileDirectory.java	(revision 1143359)
+++ lucene/src/java/org/apache/lucene/store/CompoundFileDirectory.java	(working copy)
@@ -78,6 +78,7 @@
     this.entries = SENTINEL;
     this.openForWrite = true;
     this.isOpen = true;
+    writer = new CompoundFileWriter(directory, fileName);
   }
   
   /** Helper method that reads CFS entries from an input stream */
@@ -269,7 +270,6 @@
   @Override
   public IndexOutput createOutput(String name) throws IOException {
     ensureOpen();
-    initWriter();
     return writer.createOutput(name);
   }
   
@@ -302,12 +302,4 @@
     throw new UnsupportedOperationException();
   }
   
-  private final void initWriter() {
-    assert openForWrite;
-    assert entries == SENTINEL;
-    if (writer == null) {
-      writer = new CompoundFileWriter(directory, fileName);
-    }
-  }
- 
 }
Index: lucene/src/java/org/apache/lucene/store/CompoundFileWriter.java
===================================================================
--- lucene/src/java/org/apache/lucene/store/CompoundFileWriter.java	(revision 1143359)
+++ lucene/src/java/org/apache/lucene/store/CompoundFileWriter.java	(working copy)
@@ -135,10 +135,7 @@
     IOException priorException = null;
     IndexOutput entryTableOut = null;
     try {
-      if (entries.isEmpty()) {
-        throw new IllegalStateException("CFS has no entries");
-      }
-      
+      initDataOut();
       if (!pendingEntries.isEmpty() || outputTaken.get()) {
         throw new IllegalStateException("CFS has pending open files");
       }
Index: lucene/src/test-framework/org/apache/lucene/store/MockCompoundFileDirectoryWrapper.java
===================================================================
--- lucene/src/test-framework/org/apache/lucene/store/MockCompoundFileDirectoryWrapper.java	(revision 1143359)
+++ lucene/src/test-framework/org/apache/lucene/store/MockCompoundFileDirectoryWrapper.java	(working copy)
@@ -19,7 +19,6 @@
 
 import java.io.IOException;
 import java.util.Collection;
-import java.util.Collections;
 
 public class MockCompoundFileDirectoryWrapper extends CompoundFileDirectory {
   private final MockDirectoryWrapper parent;
@@ -31,11 +30,7 @@
     this.name = name;
     this.parent = parent;
     this.delegate = delegate;
-    if (forWrite) {
-      super.initForWrite();
-    } else {
-      super.initForRead(Collections.<String,FileEntry>emptyMap());
-    }
+    // don't initialize here since we delegate everything - if not initialized a direct call will cause an assert to fail!
     parent.addFileHandle(this, name, !forWrite);
   }
   
@@ -51,12 +46,8 @@
 
   @Override
   public synchronized void close() throws IOException {
-    try {
-      delegate.close();
-      parent.removeOpenFile(this, name);
-    } finally {
-      super.close();
-    }
+    delegate.close();
+    parent.removeOpenFile(this, name);
   }
 
   @Override
Index: lucene/src/test/org/apache/lucene/index/TestCompoundFile.java
===================================================================
--- lucene/src/test/org/apache/lucene/index/TestCompoundFile.java	(revision 1143359)
+++ lucene/src/test/org/apache/lucene/index/TestCompoundFile.java	(working copy)
@@ -21,8 +21,6 @@
 import java.io.File;
 
 import org.apache.lucene.util.LuceneTestCase;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
 
 import org.apache.lucene.store.CompoundFileDirectory;
 import org.apache.lucene.store.IndexOutput;
@@ -35,24 +33,6 @@
 
 public class TestCompoundFile extends LuceneTestCase
 {
-    /** Main for running test case by itself. */
-    public static void main(String args[]) {
-        TestRunner.run (new TestSuite(TestCompoundFile.class));
-//        TestRunner.run (new TestCompoundFile("testSingleFile"));
-//        TestRunner.run (new TestCompoundFile("testTwoFiles"));
-//        TestRunner.run (new TestCompoundFile("testRandomFiles"));
-//        TestRunner.run (new TestCompoundFile("testClonedStreamsClosing"));
-//        TestRunner.run (new TestCompoundFile("testReadAfterClose"));
-//        TestRunner.run (new TestCompoundFile("testRandomAccess"));
-//        TestRunner.run (new TestCompoundFile("testRandomAccessClones"));
-//        TestRunner.run (new TestCompoundFile("testFileNotFound"));
-//        TestRunner.run (new TestCompoundFile("testReadPastEOF"));
-
-//        TestRunner.run (new TestCompoundFile("testIWCreate"));
-
-    }
-
-
     private Directory dir;
 
 
@@ -717,5 +697,16 @@
     cfr.close();
     newDir.close();
   }
+  
+  public void testEmptyCFS() throws IOException {
+    Directory newDir = newDirectory();
+    CompoundFileDirectory csw = newDir.createCompoundOutput("d.cfs");
+    csw.close();
 
+    CompoundFileDirectory csr = newDir.openCompoundInput("d.cfs", 1024);
+    assertEquals(0, csr.listAll().length);
+    csr.close();
+
+    newDir.close();
+  }
 }
