I worked around it using my own FileStream class. Its basically the same as the original one, except it does not create a new FileInputStream in getStream (which IMO is broken by design as noone ever closes this stream).
public class FileStream extends ContentStreamBase { private final java.io.FileInputStream file; public FileStream(String name, Long size, String sourceInfo, final java.io.FileInputStream f) throws IOException { this.file = f; this.contentType = null; name = name; size = size; sourceInfo = sourceInfo; } @Override public Reader getReader() throws IOException { final String charset = getCharsetFromContentType(this.contentType); return charset == null ? new InputStreamReader(this.file) : new InputStreamReader(this.file, charset); } public InputStream getStream() throws IOException { return this.file; } } You can use it like: FileInputStream f = null; try { f = new FileInputStream(file); FileStream fileInputStream = new FileStream(file.getName(), file.length(), file.toURI().toString(), f); up.addContentStream(fileInputStream); // DO SOMETHING } finally { if (f != null) { f.close(); } } This isn't exactly beauty code but at least it works this way. Would be great if someone would come up with a better idea for solrj 1.5 Regards, Chris Am 02.02.2010 13:27, schrieb Christoph Brill: > Hi list, > > I'm using ContentStreamUpdateRequest.addFile(File) to index a bunch of > documents. This works fine unless the stream created in addFile doesn't > seem to get closed. This causes issues because my process has to many > open files. > > It's a bug, right? > > Regards, > Chris