jmeter-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: Questions about DataSourceElement
Date Mon, 05 Jun 2017 19:20:15 GMT
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