From
https://stackoverflow.com/questions/355089/difference-between-stringbuilder-and-stringbuffer

“ StringBuffer
<http://docs.oracle.com/javase/8/docs/api/java/lang/StringBuffer.html> is
synchronized, StringBuilder
<http://docs.oracle.com/javase/8/docs/api/java/lang/StringBuilder.html> is
not.”

So if threading and Java memory model requirements are managed already by
the code, StringBuilder will be more efficient. Otherwise StringBuffer is
the right choice.

Ilan

On Sat 6 Jun 2020 at 22:48, Erick Erickson <erickerick...@gmail.com> wrote:

> When is there a good reason to use StringBuffer rather than StringBuilder?
> While going through some of the warnings I happened to run across a few of
> these. I haven’t changed them, and at least one (AuditEvent) has a comment
> about back-compat and is quite recent…
>
> Otherwise I though StringBuilder was preferred. Assuming the one in
> AuditEvent is required, can/should we exclude only that one (and any other
> legitimate ones) from ForbiddenAPI check and add StringBuffer to the check?
>
> Worth a JIRA? Or has this been discussed before and we just live with it?
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
> For additional commands, e-mail: dev-h...@lucene.apache.org
>
>

Reply via email to