[ 
https://issues.apache.org/jira/browse/SOLR-11004?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16074140#comment-16074140
 ] 

Jason Gerlowski edited comment on SOLR-11004 at 7/5/17 12:57 AM:
-----------------------------------------------------------------

Patch attached; a few notes:

- all SolrClient Builders now extend {{SolrClientBuilder}}
- was able to move 4 setters: {{withHttpClient}}, {{withResponseParser}}, 
{{withConnectionTimeout}}, and {{withSocketTimeout}}.  This number will grow 
pretty quickly though as the SolrClient setters gain Builder equivalent methods 
(see SOLR-8975) 
- A naive implementation would have the SolrClientBuilder setters return a 
SolrClientBuilder reference.  This introduces limitations on the order that 
setters can be called in.  This appears to be a well documented problem when 
creating Builders.  So I implemented the solution detailed 
[here|https://stackoverflow.com/questions/17164375/subclassing-a-java-builder-class],
 which involves using generics to allow SolrClientBuilder to return a reference 
typed as the concrete class.

Tests and precommit pass.


was (Author: gerlowskija):
Patch attached; a few notes:

- all SolrClient Builders now extend {{SolrClientBuilder}}
- was able to move 4 setters: {{withHttpClient}}, {{withResponseParser}}, 
{{withConnectionTimeout}}, and {{withSocketTimeout}}.  This number will grow 
pretty quickly though as the SolrClient setters gain Builder equivalent methods 
(see SOLR-8975) 
- A naive implementation would have the SolrClientBuilder setters return a 
SolrClientBuilder reference.  This would cause problems if a Builder method 
chain attempted to call a subclass method after calling a SolrClientBuilder 
method.  This appears to be a well understood problem when creating Builders.  
So I implemented the solution detailed 
[here|https://stackoverflow.com/questions/17164375/subclassing-a-java-builder-class],
 which involves using generics to allow SolrClientBuilder to return a reference 
typed as the concrete class.

> Consolidate SolrClient Builder code in abstract parent class
> ------------------------------------------------------------
>
>                 Key: SOLR-11004
>                 URL: https://issues.apache.org/jira/browse/SOLR-11004
>             Project: Solr
>          Issue Type: Improvement
>      Security Level: Public(Default Security Level. Issues are Public) 
>          Components: SolrJ
>    Affects Versions: master (8.0)
>            Reporter: Jason Gerlowski
>            Priority: Minor
>             Fix For: master (8.0)
>
>         Attachments: SOLR-11004.patch
>
>
> As [~anshumg] pointed out in SOLR-10456, the Builder code for each SolrClient 
> has a lot of duplication in it.
> For example, each SolrClient allows configuration of the connection timeout: 
> all 4 builders have a field to store this value, all 4 builders have a 
> {{withConnectionTimeout}} method to set this value, and all 4 builders have 
> very similar Javadocs documenting what this value can be used for.
> The same can be said for 5 or 6 other properties common to most/all 
> SolrClient's.
> This duplication could be removed by creating an abstract SolrClientBuilder 
> class, which each of the specific Builders extend.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to