lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r687046 - in /lucene/java/trunk/src/java/org/apache/lucene/index: SegmentReader.java TermVectorsReader.java
Date Tue, 19 Aug 2008 13:01:12 GMT
Author: mikemccand
Date: Tue Aug 19 06:01:11 2008
New Revision: 687046

URL: http://svn.apache.org/viewvc?rev=687046&view=rev
Log:
LUCENE-1249: fix small issues with TermVectorsReader.clone

Modified:
    lucene/java/trunk/src/java/org/apache/lucene/index/SegmentReader.java
    lucene/java/trunk/src/java/org/apache/lucene/index/TermVectorsReader.java

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/SegmentReader.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/SegmentReader.java?rev=687046&r1=687045&r2=687046&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/SegmentReader.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/SegmentReader.java Tue Aug 19 06:01:11
2008
@@ -924,9 +924,14 @@
    * @return TermVectorsReader
    */
   private TermVectorsReader getTermVectorsReader() {
+    assert termVectorsReaderOrig != null;
     TermVectorsReader tvReader = (TermVectorsReader)termVectorsLocal.get();
     if (tvReader == null) {
-      tvReader = (TermVectorsReader)termVectorsReaderOrig.clone();
+      try {
+        tvReader = (TermVectorsReader)termVectorsReaderOrig.clone();
+      } catch (CloneNotSupportedException cnse) {
+        return null;
+      }
       termVectorsLocal.set(tvReader);
     }
     return tvReader;

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/TermVectorsReader.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/TermVectorsReader.java?rev=687046&r1=687045&r2=687046&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/TermVectorsReader.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/TermVectorsReader.java Tue Aug 19 06:01:11
2008
@@ -523,19 +523,17 @@
     }
   }
 
-  protected Object clone() {
+  protected Object clone() throws CloneNotSupportedException {
     
-    if (tvx == null || tvd == null || tvf == null)
-      return null;
-    
-    TermVectorsReader clone = null;
-    try {
-      clone = (TermVectorsReader) super.clone();
-    } catch (CloneNotSupportedException e) {}
-
-    clone.tvx = (IndexInput) tvx.clone();
-    clone.tvd = (IndexInput) tvd.clone();
-    clone.tvf = (IndexInput) tvf.clone();
+    final TermVectorsReader clone = (TermVectorsReader) super.clone();
+
+    // These are null when a TermVectorsReader was created
+    // on a segment that did not have term vectors saved
+    if (tvx != null && tvd != null && tvf != null) {
+      clone.tvx = (IndexInput) tvx.clone();
+      clone.tvd = (IndexInput) tvd.clone();
+      clone.tvf = (IndexInput) tvf.clone();
+    }
     
     return clone;
   }



Mime
View raw message