title: How do I upgrade from DefaultHttpClient() to HttpClientBuilder.create().build()?
body: <p>I have a routine which checks if a record has been indexed by Solr. I have a deprecated method of creating a HTTPClient which I'm trying to remove:</p>
  
  <ul>
  <li><p>From</p>
  
  <p>DefaultHttpClient httpClient = new DefaultHttpClient();</p></li>
  <li><p>To</p>
  
  <p>CloseableHttpClient httpClient = HttpClientBuilder.create().build();</p></li>
  </ul>
  
  <p>The problem I now have is that after 2 call to the URL, the 3rd attempt seems to hang. I'm not quite sure what I'm missing if anyone can help please?</p>
  
  <p>This is my complete method which I've extracted out into a test:</p>
  
  <pre><code>@Test
  public void checkUntilRecordAvailable() {
      String output;
  
      String solrSingleJobURL = "http://solr01.prod.efinancialcareers.com:8080/solr/jobSearchCollection/select?q=id%3A7618769%0A&amp;fl=*&amp;wt=json&amp;indent=true";
  
      CloseableHttpClient httpClient = HttpClientBuilder.create().build();
      HttpGet httpGet = new HttpGet(solrSingleJobURL);
  
      StringBuilder jobResponseBuilder;
      Gson gson = new Gson();
  
      while (true) {
          System.out.print("WAITING FOR SOLR PARTIAL TO RUN " + solrSingleJobURL);
  
          jobResponseBuilder = new StringBuilder();
  
          try {
              HttpResponse response = httpClient.execute(httpGet);
  
              BufferedReader br = new BufferedReader(new InputStreamReader((response.getEntity().getContent())));
  
              while ((output = br.readLine()) != null) {
                  System.out.println(output);
                  jobResponseBuilder.append(output);
              }
  
              JobResponse jobResponse = gson.fromJson(jobResponseBuilder.toString(), JobResponse.class);
              Long numberOfRecordsFound = jobResponse.getNumberOfRecordsFound();
  
              if (numberOfRecordsFound == 0) {
                  System.out.println("- PAUSE FOR 10 SECONDS UNTIL NEXT CHECK");
  
                  Thread.sleep(5000);
              } else {
                  System.out.println(" RECORD FOUND ");
                  httpClient.close();
                  break;
              }
          } catch (IOException e) {
              e.printStackTrace();
          } catch (InterruptedException e) {
              e.printStackTrace();
          }
      }
  }
  </code></pre>