With a null argument, we can end up creating quite a few empty strings,
which end up being non-shared. Place an explicit check and return an
interned empty string instead.
Change-Id: I4fd9126c9502f2c80c76ca3bb38aa94a99d3ae4b
Signed-off-by: Robert Varga <rovarga@cisco.com>
@VisibleForTesting
static String replaceAllIllegalChars(final StringBuilder stringBuilder){
- return UNICODE_CHAR_PATTERN.matcher(stringBuilder).replaceAll("\\\\\\\\u");
+ final String ret = UNICODE_CHAR_PATTERN.matcher(stringBuilder).replaceAll("\\\\\\\\u");
+ return ret.isEmpty() ? "" : ret;
}
-
}