StringJoiner: detect or fix delimiter collision?
stevenschlansker at gmail.com
Tue Jul 23 20:56:34 UTC 2013
On Jul 23, 2013, at 1:37 PM, ph <philip.hodges at bluewin.ch> wrote:
> The omission of that very complexity is a copious source of bugs that breaks
> applications in production, and is extremely useful and interesting to the
> black hat community.
> It should not be possible to call a joiner without escaping or quoting or
> catching an exception or explicitly waiving the complexity. Of course there
> will still be some users who roll their own, blissfully unaware of the
> existence of StringJoiner. But for those who do discover it, the important
> value to add is not convenience, but safety.
> Maybe you could even retrofit it to Arrays.toString(), which is exactly such
> a toy interface only good for things like logging where delimiter collision
> doesn't usually matter.
> At the very least can you please cover it in the examples so that people
> can't completely overlook it?
The current behavior is similar to other languages, simple to understand, and seems to not be "surprising" to most people.
Why would you not write your data out as e.g. JSON? Then all of the tricky cases are handled correctly for you.
More information about the core-libs-dev