Alternate fix for #1319

Turns out the issue wasn't with an empty string returning an empty array, but a string with just `,`.
```
jshell> ",".split(",")
$1 ==> String[0] {  }
```
A non-intuitive edge case in my opinion.
This commit is contained in:
Tyler Benson 2020-04-07 12:35:20 -04:00
parent 176b9c0121
commit e7f0d2db12
1 changed files with 7 additions and 4 deletions

View File

@ -299,12 +299,15 @@ public final class OpenTracing32 implements TracerAPI {
extracted = new HashMap<>();
for (final String key : getter.keys(carrier)) {
// extracted header value
String s = getter.get(carrier, key);
String value = getter.get(carrier, key);
// in case of multiple values in the header, need to parse
if (s != null && !s.isEmpty()) {
s = s.split(",")[0].trim();
if (value != null) {
final String[] split = value.split(",");
if (split.length > 0) {
value = split[0].trim();
}
}
extracted.put(key, s);
extracted.put(key, value);
}
}