diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 99ec9bc097f..f442bf62eac 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -126,7 +126,8 @@ Optimizations * SOLR-5044: Admin UI - Note on Core-Admin about directories while creating core (steffkes) -* SOLR-5134: Have HdfsIndexOutput extend BufferedIndexOutput. (Mark Miller) +* SOLR-5134: Have HdfsIndexOutput extend BufferedIndexOutput. + (Mark Miller, Uwe Schindler) Other Changes ---------------------- diff --git a/solr/core/src/java/org/apache/solr/store/hdfs/HdfsDirectory.java b/solr/core/src/java/org/apache/solr/store/hdfs/HdfsDirectory.java index 6a4491a9d0d..640e125b0d6 100644 --- a/solr/core/src/java/org/apache/solr/store/hdfs/HdfsDirectory.java +++ b/solr/core/src/java/org/apache/solr/store/hdfs/HdfsDirectory.java @@ -34,8 +34,8 @@ import org.apache.lucene.store.IOContext; import org.apache.lucene.store.IndexInput; import org.apache.lucene.store.IndexOutput; import org.apache.lucene.store.NoLockFactory; +import org.apache.lucene.util.IOUtils; import org.apache.solr.store.blockcache.CustomBufferedIndexInput; -import org.apache.solr.util.IOUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -63,7 +63,7 @@ public class HdfsDirectory extends Directory { fileSystem.mkdirs(hdfsDirPath); } } catch (Exception e) { - IOUtils.closeQuietly(fileSystem); + org.apache.solr.util.IOUtils.closeQuietly(fileSystem); throw new RuntimeException("Problem creating directory: " + hdfsDirPath, e); } @@ -225,12 +225,14 @@ public class HdfsDirectory extends Directory { @Override public void close() throws IOException { + IOException priorE = null; try { super.close(); - } catch (Throwable t) { - LOG.error("Error while closing", t); + } catch (IOException ioe) { + priorE = ioe; + } finally { + IOUtils.closeWhileHandlingException(priorE, writer); } - writer.close(); } @Override diff --git a/solr/core/src/java/org/apache/solr/store/hdfs/HdfsFileWriter.java b/solr/core/src/java/org/apache/solr/store/hdfs/HdfsFileWriter.java index 941f9f6da19..459a6d13fe9 100644 --- a/solr/core/src/java/org/apache/solr/store/hdfs/HdfsFileWriter.java +++ b/solr/core/src/java/org/apache/solr/store/hdfs/HdfsFileWriter.java @@ -17,6 +17,7 @@ package org.apache.solr.store.hdfs; * limitations under the License. */ +import java.io.Closeable; import java.io.IOException; import java.util.EnumSet; @@ -31,7 +32,7 @@ import org.apache.lucene.store.DataOutput; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class HdfsFileWriter extends DataOutput { +public class HdfsFileWriter extends DataOutput implements Closeable { public static Logger LOG = LoggerFactory.getLogger(HdfsFileWriter.class); public static final String HDFS_SYNC_BLOCK = "solr.hdfs.sync.block";