Author: markrmiller
Date: Sun Sep 27 13:54:37 2009
New Revision: 819313
URL: http://svn.apache.org/viewvc?rev=819313&view=rev
Log:
SOLR-1466: Fix File descriptor leak in SnapPuller
Modified:
lucene/solr/trunk/src/java/org/apache/solr/handler/SnapPuller.java
Modified: lucene/solr/trunk/src/java/org/apache/solr/handler/SnapPuller.java
URL:
http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/handler/SnapPuller.java?rev=819313&r1=819312&r2=819313&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/handler/SnapPuller.java
(original)
+++ lucene/solr/trunk/src/java/org/apache/solr/handler/SnapPuller.java Sun Sep
27 13:54:37 2009
@@ -832,6 +832,8 @@
long bytesDownloaded = 0;
FileChannel fileChannel;
+
+ private FileOutputStream fileOutputStream;
byte[] buf = new byte[1024 * 1024];
@@ -850,7 +852,7 @@
private Long indexVersion;
FileFetcher(File dir, Map<String, Object> fileDetails, String saveAs,
- boolean isConf, long latestVersion) throws
FileNotFoundException {
+ boolean isConf, long latestVersion) throws IOException {
this.copy2Dir = dir;
this.fileName = (String) fileDetails.get(NAME);
this.size = (Long) fileDetails.get(SIZE);
@@ -862,7 +864,10 @@
indexVersion = latestVersion;
this.file = new File(copy2Dir, saveAs);
- this.fileChannel = new FileOutputStream(file).getChannel();
+
+ this.fileOutputStream = new FileOutputStream(file);
+ this.fileChannel = this.fileOutputStream.getChannel();
+
if (includeChecksum)
checksum = new Adler32();
}
@@ -992,8 +997,8 @@
*/
private void cleanup() {
try {
- //close the file
- fileChannel.close();
+ //close the FileOutputStream (which also closes the Channel)
+ fileOutputStream.close();
} catch (Exception e) {/* noop */
LOG.error("Error closing the file stream: "+ this.saveAs ,e);
}