jmeter-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Felix Schumacher <felix.schumac...@internetallee.de>
Subject Re: Questions about DataSourceElement
Date Mon, 05 Jun 2017 19:30:31 GMT
Am 05.06.2017 um 21:25 schrieb Philippe Mouawad:
> http://www.pellegrino.link/2015/08/22/string-concatenation-with-java-8.html
Nice write-up, but it seems to cover the dynamic string concatenation 
case  more than my described static one. Or did I miss something?

>
> On Mon, Jun 5, 2017 at 9:20 PM, sebb <sebbaz@gmail.com> wrote:
>
>> On 5 June 2017 at 18:27, Felix Schumacher
>> <felix.schumacher@internetallee.de> wrote:
>>> Hi all,
>>>
>>> while looking at the javadocs for DataSourceElement, I found a couple of
>>> things, that look odd to me.
>>>
>>> a) Instead of string concatenation with "+" for static strings, often a
>>> Stringbuilder is used. So instead of:
>>>
>>> String result = "shared: " + shared + " user: " + username + ...
>>>
>>> The code looks like
>>>
>>> StringBuilder builder = new StringBuilder(40);
>>> builder.append("shared: ").append(shared)
>>>      .append("user: ").append(username)
>>>      ...
>>> String result = builder.toString();
>>>
>>> I think the compiler will generate the same code for the former and the
>>> latter. To me the string concatenation looks cleaner.
>>>
>>> Is there any reason to use the latter code for static strings?
>> Probably historic.
>> I think originally the Java compiler was not clever enough to use a
>> StringBuilder (indeed before Java 5 it did not exist).
>>
>>> b) In the inner class  DataSourceComponentImpl there is some (really
>> minor)
>>> code duplication in getConnectionInfo and getConnection. But my real
>> concern
>>> is, that getConnection checks for a null BasicDataSource, while
>>> getConnectionInfo doesn't.
>>>
>>> What is the logic behind this?
>>>
>>> Regards,
>>>
>>>   Felix
>>>
>
>


Mime
View raw message