HttpClient#execute についてもう一つ

ええと、例の方式を使って、ファイルの download な通信をしたら Socket 例外が発生するのでコメントアウトせざるを得なかった、という事がありました。
どなたかご存知な方がいらっしゃるかも、ということでエントリを入れておきます。

実装としては

以下。問題ありそうな所は書き換えてますが、大筋は以下の通り。

            FileOutputStream fileOutput = new FileOutputStream(file);

            HttpGet httpGet = new HttpGet("http://" + HOSTNAME + "/" + path);
            InputStream inputStream = mHttpClient.execute(httpGet,
                    new ResponseHandler<InputStream>() {

                        @Override
                        public InputStream handleResponse(HttpResponse response)
                                throws ClientProtocolException, IOException {
                            switch (response.getStatusLine().getStatusCode()) {
                            case HttpStatus.SC_OK:
                                return response.getEntity().getContent();
                            default:
                                throw new RuntimeException("HTTP Status error");
                            }
                        }
                
            });
            
            byte[] buffer = new byte[1024];
            int bufferLength = 0;
        
            while((bufferLength = inputStream.read(buffer)) > 0) {
                fileOutput.write(buffer, 0, bufferLength);
            }
        
            inputStream.close();
            fileOutput.close();

読んで書いて、というあたりで、だったと記憶しています。download するサイズがそれなりに大きいものだったので HttpResponse なオブジェクトが解放されてしまっているのかなぁ、というのが今の感想なんですが、もう試験できるナニが無い。