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

Adrian Shum commented on LANG-833:
----------------------------------

Support for using StringBuilder in ToStringBuilder.  I believe lang3 allow 
breaking certain level of backward compatibility (and afaik it did).  And, most 
important is, the suggested usage of ToStringBuilder is mostly for a 
short-lived string building that is rarely shared between threads.  

A compromise can be allowing an (optional) extra ctor argument in 
ToStringBuilder to denote whether we want it to be thread-safe or not (we can 
keep the default as thread-safe).  Internally, instead of using 
StringBuffer/StringBuilder directly, declare buffer as AbstractStringBuilder 
instead (which is the parent of StringBuffer and StringBuilder).  Instantiate 
StringBuffer or StringBuilder according to the ctor argument.

For people who want better performance, they can just explicitly change the 
usage of ToStringBuilder from new ToStringBuilder(....) to new 
ToSTringBuilder(..., THREAD_UNSAFE).  

Sounds feasible to me.  :P
                
> ToStringBuilder should use StringBuilder
> ----------------------------------------
>
>                 Key: LANG-833
>                 URL: https://issues.apache.org/jira/browse/LANG-833
>             Project: Commons Lang
>          Issue Type: Improvement
>          Components: lang.*
>    Affects Versions: 3.1
>            Reporter: Shevek
>
> Rewriting as lang3 but still using StringBuffer (synchronized) looks like a 
> missed opportunity. Please use StringBuilder.
> Suggest audit for uses of StringBuffer in lang3 overall. No cause for it.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to