Re: Closing IndexWriter object after each file causes NullPointerException?

2004-04-14 Thread Brisbart Franck
I'm not sure to understand what is your problem.
Anyway, the writeLock is used to avoid 2 different writers (or reader if 
you use 'delete') to modify the same index.
What do you mean by first file ??

Franck

jitender ahuja wrote:
Hi,

Ok, but what is the use of  the writeLock, as the directory is
modified anyway!
As if the writeLock is an issue then then the index directory should have
index information only for the first file.
Thanks,
Jitender
- Original Message - 
From: "Brisbart Franck" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; "Lucene Users List"
<[EMAIL PROTECTED]>
Sent: Tuesday, April 13, 2004 10:15 PM
Subject: Re: Closing IndexWriter object after each file causes
NullPointerException?



If you close an IndexWriter more than once, the release of the writeLock
 creates a NullPointerException.
You should clean your code and close your writer only once. Anyway, I
don't know why there's no test on the 'writeLock' as in the 'finalize'
method.
I think it's a little error, so I suggest the attached patch to fix that.
Franck Brisbart

jitender ahuja wrote:

Hi,
Can anyone tell what is the cause of error for the following error
as the source of error is not any of the following:
a) Index directory closing after each file of the directory (to be
indexed) : verified by the changing directory size, with the changing
number of files to be indexed
b) IndexWriter object being closed out : verified by checking the
IndexWriter object ( here, writ) being a non-null object, by the line:
   System.out.println(writ != null); in the attached code
Error output:
java.lang.NullPointerException
   at org.apache.lucene.index.IndexWriter.close(Unknown Source)
   at IndexDatanew.indexDocs(IndexDatanew.java:89)
   at IndexDatanew.indexDocs(IndexDatanew.java:50)
   at IndexDatanew.main(IndexDatanew.java:25)
The code that causes this error is working fine otherwise (i.e. for
indexing purposes) and is "attached"; the output in detail for a
directory of 2 files is also attached.:
Thanks
Jitender


C:\lucroche>java IndexDatanew E:\freebooks\books\whole\jiten
Index Directory: E:\freebooks\books\whole\jiten
2
E:\freebooks\books\whole\jiten\Copy of TIJ3_c.htm
adding: E:\freebooks\books\whole\jiten\Copy of TIJ3_c.htm
File contents from buffer:
E:\freebooks\books\whole\jiten\Copy of TIJ3_c.htm
false
E:\freebooks\books\whole\jiten\TIJ3_c.htm
adding: E:\freebooks\books\whole\jiten\TIJ3_c.htm
File contents from buffer:
E:\freebooks\books\whole\jiten\TIJ3_c.htm
false
java.lang.NullPointerException
   at org.apache.lucene.index.IndexWriter.close(Unknown Source)
   at IndexDatanew.indexDocs(IndexDatanew.java:89)
   at IndexDatanew.indexDocs(IndexDatanew.java:50)
   at IndexDatanew.main(IndexDatanew.java:25)




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


--
Franck Brisbart
R&D
http://www.kelkoo.com






Index: IndexWriter.java
===
RCS file:
/home/cvspublic/jakarta-lucene/src/java/org/apache/lucene/index/IndexWriter.
java,v
retrieving revision 1.28
diff -u -r1.28 IndexWriter.java
--- IndexWriter.java 25 Mar 2004 19:34:53 - 1.28
+++ IndexWriter.java 13 Apr 2004 16:39:56 -
@@ -235,8 +235,10 @@
  public synchronized void close() throws IOException {
flushRamSegments();
ramDirectory.close();
-writeLock.release();  // release write lock
-writeLock = null;
+if (writeLock != null) {
+  writeLock.release();  // release write lock
+  writeLock = null;
+}
directory.close();
  }



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


--
Franck Brisbart
R&D
http://www.kelkoo.com
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Closing IndexWriter object after each file causes NullPointerException?

2004-04-14 Thread jitender ahuja
Hi,

Ok, but what is the use of  the writeLock, as the directory is
modified anyway!
As if the writeLock is an issue then then the index directory should have
index information only for the first file.

Thanks,
Jitender

- Original Message - 
From: "Brisbart Franck" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; "Lucene Users List"
<[EMAIL PROTECTED]>
Sent: Tuesday, April 13, 2004 10:15 PM
Subject: Re: Closing IndexWriter object after each file causes
NullPointerException?


> If you close an IndexWriter more than once, the release of the writeLock
>   creates a NullPointerException.
> You should clean your code and close your writer only once. Anyway, I
> don't know why there's no test on the 'writeLock' as in the 'finalize'
> method.
> I think it's a little error, so I suggest the attached patch to fix that.
>
> Franck Brisbart
>
>
> jitender ahuja wrote:
> > Hi,
> >  Can anyone tell what is the cause of error for the following error
> > as the source of error is not any of the following:
> > a) Index directory closing after each file of the directory (to be
> > indexed) : verified by the changing directory size, with the changing
> >  number of files to be indexed
> > b) IndexWriter object being closed out : verified by checking the
> > IndexWriter object ( here, writ) being a non-null object, by the line:
> > System.out.println(writ != null); in the attached code
> >
> >
> > Error output:
> >  java.lang.NullPointerException
> > at org.apache.lucene.index.IndexWriter.close(Unknown Source)
> > at IndexDatanew.indexDocs(IndexDatanew.java:89)
> > at IndexDatanew.indexDocs(IndexDatanew.java:50)
> > at IndexDatanew.main(IndexDatanew.java:25)
> >
> > The code that causes this error is working fine otherwise (i.e. for
> > indexing purposes) and is "attached"; the output in detail for a
> > directory of 2 files is also attached.:
> >
> > Thanks
> > Jitender
> >
> >
> > 
> >
> > C:\lucroche>java IndexDatanew E:\freebooks\books\whole\jiten
> > Index Directory: E:\freebooks\books\whole\jiten
> > 2
> > E:\freebooks\books\whole\jiten\Copy of TIJ3_c.htm
> > adding: E:\freebooks\books\whole\jiten\Copy of TIJ3_c.htm
> > File contents from buffer:
> > E:\freebooks\books\whole\jiten\Copy of TIJ3_c.htm
> > false
> > E:\freebooks\books\whole\jiten\TIJ3_c.htm
> > adding: E:\freebooks\books\whole\jiten\TIJ3_c.htm
> > File contents from buffer:
> > E:\freebooks\books\whole\jiten\TIJ3_c.htm
> > false
> > java.lang.NullPointerException
> > at org.apache.lucene.index.IndexWriter.close(Unknown Source)
> > at IndexDatanew.indexDocs(IndexDatanew.java:89)
> > at IndexDatanew.indexDocs(IndexDatanew.java:50)
> > at IndexDatanew.main(IndexDatanew.java:25)
> >
> >
> >
> > 
> >
> > -
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
>
>
> -- 
> Franck Brisbart
> R&D
> http://www.kelkoo.com
>






> Index: IndexWriter.java
> ===
> RCS file:
/home/cvspublic/jakarta-lucene/src/java/org/apache/lucene/index/IndexWriter.
java,v
> retrieving revision 1.28
> diff -u -r1.28 IndexWriter.java
> --- IndexWriter.java 25 Mar 2004 19:34:53 - 1.28
> +++ IndexWriter.java 13 Apr 2004 16:39:56 -
> @@ -235,8 +235,10 @@
>public synchronized void close() throws IOException {
>  flushRamSegments();
>  ramDirectory.close();
> -writeLock.release();  // release write lock
> -writeLock = null;
> +if (writeLock != null) {
> +  writeLock.release();  // release write lock
> +  writeLock = null;
> +}
>  directory.close();
>}
>
>


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Closing IndexWriter object after each file causes NullPointerException?

2004-04-13 Thread Brisbart Franck
If you close an IndexWriter more than once, the release of the writeLock 
 creates a NullPointerException.
You should clean your code and close your writer only once. Anyway, I 
don't know why there's no test on the 'writeLock' as in the 'finalize' 
method.
I think it's a little error, so I suggest the attached patch to fix that.

Franck Brisbart

jitender ahuja wrote:
Hi,
 Can anyone tell what is the cause of error for the following error 
as the source of error is not any of the following:
a) Index directory closing after each file of the directory (to be 
indexed) : verified by the changing directory size, with the changing
 number of files to be indexed
b) IndexWriter object being closed out : verified by checking the 
IndexWriter object ( here, writ) being a non-null object, by the line:
System.out.println(writ != null); in the attached code
 
 
Error output:
 java.lang.NullPointerException
at org.apache.lucene.index.IndexWriter.close(Unknown Source)
at IndexDatanew.indexDocs(IndexDatanew.java:89)
at IndexDatanew.indexDocs(IndexDatanew.java:50)
at IndexDatanew.main(IndexDatanew.java:25)
 
The code that causes this error is working fine otherwise (i.e. for 
indexing purposes) and is "attached"; the output in detail for a
directory of 2 files is also attached.:
 
Thanks
Jitender



C:\lucroche>java IndexDatanew E:\freebooks\books\whole\jiten
Index Directory: E:\freebooks\books\whole\jiten
2
E:\freebooks\books\whole\jiten\Copy of TIJ3_c.htm
adding: E:\freebooks\books\whole\jiten\Copy of TIJ3_c.htm
File contents from buffer:
E:\freebooks\books\whole\jiten\Copy of TIJ3_c.htm
false
E:\freebooks\books\whole\jiten\TIJ3_c.htm
adding: E:\freebooks\books\whole\jiten\TIJ3_c.htm
File contents from buffer:
E:\freebooks\books\whole\jiten\TIJ3_c.htm
false
java.lang.NullPointerException
at org.apache.lucene.index.IndexWriter.close(Unknown Source)
at IndexDatanew.indexDocs(IndexDatanew.java:89)
at IndexDatanew.indexDocs(IndexDatanew.java:50)
at IndexDatanew.main(IndexDatanew.java:25)
 



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


--
Franck Brisbart
R&D
http://www.kelkoo.com
Index: IndexWriter.java
===
RCS file: 
/home/cvspublic/jakarta-lucene/src/java/org/apache/lucene/index/IndexWriter.java,v
retrieving revision 1.28
diff -u -r1.28 IndexWriter.java
--- IndexWriter.java25 Mar 2004 19:34:53 -  1.28
+++ IndexWriter.java13 Apr 2004 16:39:56 -
@@ -235,8 +235,10 @@
   public synchronized void close() throws IOException {
 flushRamSegments();
 ramDirectory.close();
-writeLock.release();  // release write lock
-writeLock = null;
+if (writeLock != null) {
+  writeLock.release();  // release write lock
+  writeLock = null;
+}
 directory.close();
   }
 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]