Hi Shawn, Thanks for your response. I am not using http client directly. I am using SolrHttpClient which is using it so I have no control. Below is a snippet of my test code:
HttpSolrClient solrSvr = new HttpSolrClient(url); SolrQuery query=new SolrQuery(); query.setQuery("xyz"); query.setStart(0); query.setRows(100); QueryResponse res=solrSvr.query(query); SolrDocumentList results=res.getResults(); Thanks, Firas -----Original Message----- From: Shawn Heisey [mailto:apa...@elyograg.org] Sent: Friday, September 04, 2015 1:21 AM To: solr-user@lucene.apache.org Subject: Re: http client mismatch On 9/3/2015 11:04 PM, Shawn Heisey wrote: > It sounds like your code is trying to assign the result of the > createClient method to an object of type SystemDefaultHttpClient. > This is a derivative type of CloseableHttpClient. This would work if > the derivation were the other direction. > > The compiler is saying that you cannot make this assignment. I tried > to put these code lines into a SolrJ program: > > SystemDefaultHttpClient sc; > sc = HttpClientUtil.createClient(someParams); I thought up an imperfect comparison to help understand why this is a problem. Think about "SystemDefaultHttpClient" as Infiniti, a brand of car. Think about "CloseableHttpClient" (the type returned by createClient) as Nissan. The Infiniti brand is owned and built by Nissan. Taking this idea further, imagine that "sc" is a parking spot that expects to hold a car made by Infiniti. Trying to park a Nissan there isn't going to work, because the parking spot owner is very picky about exactly what gets to park there. The reverse works just fine ... an Infiniti can take a spot made for a Nissan, and the parking spot owner will be very happy, because an Infiniti *is* a Nissan, only fancier. Similarly, a SystemDefaultHttpClient is a CloseableHttpClient, but a CloseableHttpClient is not a SystemDefaultHttpClient. Thanks, Shawn