I tried to fix it in CommonsHttpSolrServer but I wasn't sure how to do it. I tried to close the stream after the method got executed, but somehow getContent() always returned null (see attached patch against solr 1.4 for my non-working attempt).
Who's responsible for closing a stream? CommonsHttpSolrServer? The caller? FileStream? I'm unsure because I don't know solrj in depth. Regards, Chris Am 02.02.2010 14:37, schrieb Mark Miller: > Broken by design? > > How about we just fix BinaryUpdateRequestHandler (and possibly > CommonsHttpSolrServer) to close the stream it gets?
>From 08b158c28ebee618ac65defe731cbbc4954977b2 Mon Sep 17 00:00:00 2001 From: Christoph Brill <christoph.br...@chamaeleon.de> Date: Tue, 2 Feb 2010 13:39:26 +0100 Subject: [PATCH] [Bugfix] Close streams after sending them --- .../client/solrj/impl/CommonsHttpSolrServer.java | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/src/solrj/org/apache/solr/client/solrj/impl/CommonsHttpSolrServer.java b/src/solrj/org/apache/solr/client/solrj/impl/CommonsHttpSolrServer.java index 62b44f1..2fd39b0 100644 --- a/src/solrj/org/apache/solr/client/solrj/impl/CommonsHttpSolrServer.java +++ b/src/solrj/org/apache/solr/client/solrj/impl/CommonsHttpSolrServer.java @@ -414,6 +414,15 @@ public class CommonsHttpSolrServer extends SolrServer //System.out.println( "EXECUTE:"+method.getURI() ); int statusCode = _httpClient.executeMethod(method); + + if (method instanceof PostMethod) { + if (((PostMethod) method).getRequestEntity() instanceof InputStreamRequestEntity) { + if (((InputStreamRequestEntity) ((PostMethod) method).getRequestEntity()).getContent() != null) { + ((InputStreamRequestEntity) ((PostMethod) method).getRequestEntity()).getContent().close(); + } + } + } + if (statusCode != HttpStatus.SC_OK) { StringBuilder msg = new StringBuilder(); msg.append( method.getStatusLine().getReasonPhrase() ); -- 1.6.6