lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Bamford <Chris.Bamf...@scalix.com>
Subject RE: New "Stream closed" exception with Java 6 - solved
Date Wed, 16 Sep 2009 16:10:47 GMT
Hoss,

It turns out that the cause of the exceptions is in fact adding an item twice - so you were
correct right at the start  :-)  I ran a test where I attempt to insert the same item twice
and guess what ...  I get a "Stream closed" exception on the 2nd attempt.
Understanding this is a great relief as it means my code structure is OK - I just wasn't handling
duplicate requests adequately.

Just a minor point: isn't Lucence in a position to detect the duplicate insertion attempt
and flag it with something less vague than "Stream closed"?  :-)

Anyway thanks to you, Mark and Grant for all your help on this - much appreciated.

- Chris

----- Original Message -----
From: Chris Hostetter <hossman_lucene@fucit.org>
Sent: Tue, 15/9/2009 6:37pm
To: java-user@lucene.apache.org
Subject: RE: New "Stream closed" exception with Java 6

: "it's possibly you just have a simple bug where you are  closing the reader before you pass
it to Lucene, 
: 
:       or maybe you are mistakenly adding the same field twice
: 
: (or in two different documents)"
: 
: Are you saying that if I were attempting to delete a doc and then add it 
: again (e.g. update), but for some reason the delete didn't work, I would 
: get a "Stream closed" exception?

Uh... no.  I didn't say anything about delets, or updates.  I'm talking 
about the java.io.Reader class.  AS i recall (not looking at it right now) 
Your stack trace showed that when lucene tried to access a an 
InputStreamReader from a Field in your document it was already closed.  
that could happen if you did something like this...

   File myFileOnDisk = new File(path);
   Reader fileContents = new InputStreamReader(new FileInputStream(myFileOnDisk));
   fileContents.close();
   doc.addField(new Field("field name", fileContents));

...but there are lots of other ways it could happen too, it's impossible 
to list all the ways it might happen without knowing where exactly that 
InputStreamReader is coming from, and where the underlying INputStream 
is coming from, and what code has refrences to either of them between the 
time it's created and the time Lucene finally attempts to read from it.

: careful about your assumptions ... you could get this same type of 
: exception even with only one thread, the stream that's being closed isn't 
: internal to Lucene, it's the InputStreamReader you supplied as the value 
: of some Field.  it's possibly you just have a simple bug where you are 
: closing hte reader before you pass it to Lucene, or maybe you are 
: mistakenly adding the saame field twice (or in two different documents)



-Hoss


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


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


Mime
View raw message