I only have the source to 4.6.1, but if you look at the constructor of
IndexWriter there, it looks like this:

  public IndexWriter(Directory d, IndexWriterConfig conf) throws
IOException {
    conf.setIndexWriter(this); // prevent reuse by other instances

The setter throws an exception if the configuration object has already been
used with another instance of IndexWriter. Therefore, it should be cloned
before being used in the constructor of IndexWriter.


On Mon, Aug 11, 2014 at 7:12 PM, Sheng <sheng...@gmail.com> wrote:

> So the indexWriterConfig.clone() failed at this step:
> clone.indexerThreadPool = indexerThreadPool
> <
> http://grepcode.com/file/repo1.maven.org/maven2/org.apache.lucene/lucene-core/4.7.0/org/apache/lucene/index/LiveIndexWriterConfig.java#LiveIndexWriterConfig.0indexerThreadPool
> >
> .clone
> <
> http://grepcode.com/file/repo1.maven.org/maven2/org.apache.lucene/lucene-core/4.7.0/org/apache/lucene/index/DocumentsWriterPerThreadPool.java#DocumentsWriterPerThreadPool.clone%28%29
> >
> ();
>
> which then failed at this step in the "indexerThreadPool"
>
>
> if (numThreadStatesActive
> <
> http://grepcode.com/file/repo1.maven.org/maven2/org.apache.lucene/lucene-core/4.7.0/org/apache/lucene/index/DocumentsWriterPerThreadPool.java#DocumentsWriterPerThreadPool.0numThreadStatesActive
> >
> != 0) {
>
>     throw new IllegalStateException
> <
> http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b27/java/lang/IllegalStateException.java#IllegalStateException
> >("clone
> this object before it is used!");
>
> }
>
>
> There is a comment right above this:
> // We should only be cloned before being used:
>
> Does this mean whenever the indexWriter gets called for
> commit/prepareCommit, etc., the corresponding indexWriterConfig object
> cannot be called with .clone() at all?
>
>
> On Mon, Aug 11, 2014 at 9:52 PM, Vitaly Funstein <vfunst...@gmail.com>
> wrote:
>
> > Looks like you have to clone it prior to using with any IndexWriter
> > instances.
> >
> >
> > On Mon, Aug 11, 2014 at 2:49 PM, Sheng <sheng...@gmail.com> wrote:
> >
> > > I tried to create a clone of indexwriteconfig with
> > > "indexWriterConfig.clone()" for re-creating a new indexwriter, but I
> > then I
> > > got this very annoying illegalstateexception: "clone this object before
> > it
> > > is used". Why does this exception happen, and how can I get around it?
> > > Thanks!
> > >
> >
>

Reply via email to