lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r621685 - /lucene/java/trunk/src/java/org/apache/lucene/index/IndexWriter.java
Date Tue, 12 Feb 2008 18:27:15 GMT
Author: mikemccand
Date: Tue Feb 12 10:27:14 2008
New Revision: 621685

URL: http://svn.apache.org/viewvc?rev=621685&view=rev
Log:
LUCENE-1175: add missing synchronization

Modified:
    lucene/java/trunk/src/java/org/apache/lucene/index/IndexWriter.java

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/IndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/IndexWriter.java?rev=621685&r1=621684&r2=621685&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/IndexWriter.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/IndexWriter.java Tue Feb 12 10:27:14
2008
@@ -3698,8 +3698,13 @@
 
       // Maybe force a sync here to allow reclaiming of the
       // disk space used by the segments we just merged:
-      if (autoCommit && doCommitBeforeMergeCFS(merge))
-        sync(false, merge.info.sizeInBytes());
+      if (autoCommit && doCommitBeforeMergeCFS(merge)) {
+        final long size;
+        synchronized(this) {
+          size = merge.info.sizeInBytes();
+        }
+        sync(false, size);
+      }
       
       success = false;
       final String compoundFileName = mergedName + "." + IndexFileNames.COMPOUND_FILE_EXTENSION;
@@ -3746,8 +3751,13 @@
     // (somewhat arbitrary) policy; we could try other
     // policies like only sync if it's been > X minutes or
     // more than Y bytes have been written, etc.
-    if (autoCommit)
-      sync(false, merge.info.sizeInBytes());
+    if (autoCommit) {
+      final long size;
+      synchronized(this) {
+        size = merge.info.sizeInBytes();
+      }
+      sync(false, size);
+    }
 
     return mergedDocCount;
   }



Mime
View raw message