lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Trejkaz <>
Subject Re: Stream Closed Exception and Lock Obtain Failed Exception while reading the file in chunks iteratively.
Date Mon, 02 Sep 2013 06:41:45 GMT
On Mon, Sep 2, 2013 at 4:10 PM, Ankit Murarka
<> wrote:
> There's a reason why Writer is being opened everytime inside a while loop. I
> usually open writer in main method itself as suggested by you and pass a
> reference to it. However what I have observed is that if my file contains
> more than 4 lakh lines, the writer.add(doc) line does not execute and throws
> an OutOfMemoryError although JVM is provided with enough heap.

The problem isn't opening it multiple times (although that does seem
unnecessary too), the problem is that half the time you're not closing

Try refactoring to always use the try(){} syntax so that all your
Closeable objects are being closed properly. You'll find all sorts of
issues with the code you posted.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message