You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Dawid Weiss (Created) (JIRA)" <ji...@apache.org> on 2012/04/16 12:04:18 UTC

[jira] [Created] (LUCENE-3991) Random shared by threads in RandomIndexWriter and MockAnalyzer

Random shared by threads in RandomIndexWriter and MockAnalyzer
--------------------------------------------------------------

                 Key: LUCENE-3991
                 URL: https://issues.apache.org/jira/browse/LUCENE-3991
             Project: Lucene - Java
          Issue Type: Task
            Reporter: Dawid Weiss
            Priority: Minor


This is currently patched by creating a non-asserting Random like this:
{code}
    public MockIndexWriter(Random r, Directory dir, IndexWriterConfig conf) throws IOException {
      super(dir, conf);
      // TODO: this should be solved in a different way; Random should not be shared (!).
      this.r = new Random(r.nextLong());
    }
{code}
and
{code}
  public MockAnalyzer(Random random, CharacterRunAutomaton runAutomaton, boolean lowerCase, CharacterRunAutomaton filter, boolean enablePositionIncrements) {
    super(new PerFieldReuseStrategy());
    // TODO: this should be solved in a different way; Random should not be shared (!).
    this.random = new Random(random.nextLong());
{code}

If you replace new Random(...) with a simple assignment you'll get errors indicating the Random instance is shared (or passed between threads). I don't know how to fix it so I left it as it was before.


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org