commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Adrian Shum (JIRA)" <>
Subject [jira] [Commented] (LANG-833) ToStringBuilder should use StringBuilder
Date Tue, 16 Oct 2012 02:59:03 GMT


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:
>             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:

View raw message