Return-Path: X-Original-To: apmail-lucene-java-user-archive@www.apache.org Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 446A6C19A for ; Tue, 12 Aug 2014 03:31:37 +0000 (UTC) Received: (qmail 75829 invoked by uid 500); 12 Aug 2014 03:31:35 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 75771 invoked by uid 500); 12 Aug 2014 03:31:35 -0000 Mailing-List: contact java-user-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-user@lucene.apache.org Delivered-To: mailing list java-user@lucene.apache.org Received: (qmail 75572 invoked by uid 99); 12 Aug 2014 03:31:34 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Aug 2014 03:31:34 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of vfunstein@gmail.com designates 209.85.212.181 as permitted sender) Received: from [209.85.212.181] (HELO mail-wi0-f181.google.com) (209.85.212.181) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Aug 2014 03:31:08 +0000 Received: by mail-wi0-f181.google.com with SMTP id bs8so5123888wib.8 for ; Mon, 11 Aug 2014 20:31:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=TC+O8k4jPaQcKWBNiGpOOvvzk3b/Tmf4Tlw/G8QAgOs=; b=f949G2HgLm2SCiGCtLh2kTveCp3Zt1JTOVxnuuGaL1f371AP7Z9X6JiO8PieZgcz6Z 3G5J+lvDDN7h7pGlacMdyN6vVtA95STWtUC9Ox8lGuWvpIRlf7NqPuivvcWe1+I89AJh u7Krt0ISwRKubMzsugy9yBlJBtydlGiYLYgheCFcOjkV2LTQhl7lSZSROsUpToo8e+cF ggzndF2rhwiHmEymANN3b+KWy7pi9vC3mjPYL3r7LtlM/3c6aAE0NEN029fqlUqesVaS T3Su9ikocNooNOvtumQa0Nxh1jSVU5olrqrrmh5JBtodwRBgZuH56iHVfyRxS85t7mDz c5Wg== MIME-Version: 1.0 X-Received: by 10.180.73.115 with SMTP id k19mr30258903wiv.35.1407814268179; Mon, 11 Aug 2014 20:31:08 -0700 (PDT) Received: by 10.194.90.6 with HTTP; Mon, 11 Aug 2014 20:31:08 -0700 (PDT) In-Reply-To: References: Date: Mon, 11 Aug 2014 20:31:08 -0700 Message-ID: Subject: Re: Problem of calling indexWriterConfig.clone() From: Vitaly Funstein To: java-user@lucene.apache.org Content-Type: multipart/alternative; boundary=f46d043749cb5d5be60500664dc1 X-Virus-Checked: Checked by ClamAV on apache.org --f46d043749cb5d5be60500664dc1 Content-Type: text/plain; charset=UTF-8 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 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 > 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 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! > > > > > > --f46d043749cb5d5be60500664dc1--