Replace StringBuffers to StringBuilders in tests

Daniel Fuchs daniel.fuchs at oracle.com
Fri Aug 27 10:42:05 UTC 2021


Hi Sergei,

I wouldn't bother replacing StringBuffers with StringDuilders in tests.
It seems a bit gratuitous - and possibly could complicate future
tests backports.

But that's my personal opinion. Others might disagree.

best regards,

-- daniel

On 27/08/2021 11:00, Sergei Ustimenko wrote:
> Hi all,
> 
> Some tests use StringBuffers instead of StringBuilders where additional thread-safety
> is not required as e.g. in test/jdk/sun/util/resources/TimeZone/Bug4640234.java:82 :
> ...
> 
> StringBuffer errors
> 
> =
> 
> new
> 
> StringBuffer(
> 
> ""
> 
> );
> 
> StringBuffer warnings
> 
> =
> 
> new
> 
> StringBuffer(
> 
> ""
> 
> );
> 
> ...
> There were some efforts to clean up core libs (e.g. java.base module in
> https://github.com/openjdk/jdk/pull/2922) and I've noticed some tests that could be
> improved as well.
> 
> Now there are about 300 tests for different modules that in general use StringBuffers
> (most probably some of them not without a reason) so is it something worth looking
> into? What you think about it?
> 
> Regards,
> Sergei
> 



More information about the core-libs-dev mailing list