From 83d745ab0c41d2ae7aa168cae2965aea56ab75e7 Mon Sep 17 00:00:00 2001 From: Otis Gospodnetic Date: Tue, 17 Aug 2004 20:53:16 +0000 Subject: [PATCH] - Small fixes from Bernhard Messer (http://issues.apache.org/bugzilla/show_bug.cgi?id=30522) PR: 30522 Obtained from: Submitted by: Bernhard Messer Reviewed by: Otis Gospodnetic git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@150443 13f79535-47bb-0310-9956-ffa450edef68 --- .../lucene/index/TermVectorsReader.java | 39 ++++++++++++++----- .../lucene/index/TermVectorsWriter.java | 19 +++++++++ 2 files changed, 49 insertions(+), 9 deletions(-) diff --git a/src/java/org/apache/lucene/index/TermVectorsReader.java b/src/java/org/apache/lucene/index/TermVectorsReader.java index 07e1e2e8fdd..e94b4f1f51e 100644 --- a/src/java/org/apache/lucene/index/TermVectorsReader.java +++ b/src/java/org/apache/lucene/index/TermVectorsReader.java @@ -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 @@ class TermVectorsReader { } - 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 @@ class TermVectorsReader { // 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]; diff --git a/src/java/org/apache/lucene/index/TermVectorsWriter.java b/src/java/org/apache/lucene/index/TermVectorsWriter.java index 68669528ed9..19ecab8f0b9 100644 --- a/src/java/org/apache/lucene/index/TermVectorsWriter.java +++ b/src/java/org/apache/lucene/index/TermVectorsWriter.java @@ -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 @@ import java.util.Vector; writer.closeDocument() } + * + * @version $Id$ + * */ final class TermVectorsWriter { public static final int FORMAT_VERSION = 1;