otis 2004/08/17 13:53:16 Modified: src/java/org/apache/lucene/index TermVectorsReader.java TermVectorsWriter.java Log: - Small fixes from Bernhard Messer (http://issues.apache.org/bugzilla/show_bug.cgi?id=30522) PR: 30522 Submitted by: Bernhard Messer Reviewed by: Otis Gospodnetic Revision Changes Path 1.3 +30 -9 jakarta-lucene/src/java/org/apache/lucene/index/TermVectorsReader.java Index: TermVectorsReader.java =================================================================== RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/index/TermVectorsReader.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- TermVectorsReader.java 6 Aug 2004 20:50:00 -0000 1.2 +++ TermVectorsReader.java 17 Aug 2004 20:53:16 -0000 1.3 @@ -1,11 +1,30 @@ package org.apache.lucene.index; +/** + * Copyright 2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import org.apache.lucene.store.Directory; import org.apache.lucene.store.InputStream; import java.io.IOException; -/** TODO: relax synchro! +/** + * FIXME: relax synchro! + * + * @version $Id$ */ class TermVectorsReader { private FieldInfos fieldInfos; @@ -41,12 +60,14 @@ } - synchronized void close() throws IOException { - // why don't we trap the exception and at least make sure that - // all streams that we can close are closed? - if (tvx != null) tvx.close(); - if (tvd != null) tvd.close(); - if (tvf != null) tvf.close(); + void close() throws IOException { + // make all effort to close up. Keep the first exception + // and throw it as a new one. + IOException keep = null; + if (tvx != null) try { tvx.close(); } catch (IOException e) { if (keep == null) keep = e; } + if (tvd != null) try { tvd.close(); } catch (IOException e) { if (keep == null) keep = e; } + if (tvf != null) try { tvf.close(); } catch (IOException e) { if (keep == null) keep = e; } + if (keep != null) throw (IOException) keep.fillInStackTrace(); } /** @@ -188,8 +209,8 @@ // If no terms - return a constant empty termvector if (numTerms == 0) return new SegmentTermVector(field, null, null); - int length = numTerms + tvf.readVInt(); - + tvf.readVInt(); + String terms[] = new String[numTerms]; int termFreqs[] = new int[numTerms]; 1.2 +19 -0 jakarta-lucene/src/java/org/apache/lucene/index/TermVectorsWriter.java Index: TermVectorsWriter.java =================================================================== RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/index/TermVectorsWriter.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- TermVectorsWriter.java 20 Feb 2004 20:14:55 -0000 1.1 +++ TermVectorsWriter.java 17 Aug 2004 20:53:16 -0000 1.2 @@ -1,5 +1,21 @@ package org.apache.lucene.index; +/** + * Copyright 2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import org.apache.lucene.store.Directory; import org.apache.lucene.store.OutputStream; import org.apache.lucene.util.StringHelper; @@ -29,6 +45,9 @@ writer.closeDocument() } </CODE> + * + * @version $Id$ + * */ final class TermVectorsWriter { public static final int FORMAT_VERSION = 1;
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]