Skip to content

Fix Extractor edge case with value of a single comma.#1356

Merged
tylerbenson merged 1 commit into
masterfrom
tyler/split-fix
Apr 9, 2020
Merged

Fix Extractor edge case with value of a single comma.#1356
tylerbenson merged 1 commit into
masterfrom
tyler/split-fix

Conversation

@tylerbenson
Copy link
Copy Markdown
Contributor

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.

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.
@tylerbenson tylerbenson requested a review from a team as a code owner April 7, 2020 16:36
@tylerbenson tylerbenson changed the title Alternate fix for #1319 Fix Extractor edge case with value of a single comma. Apr 7, 2020
Comment on lines +306 to +308
if (split.length > 0) {
value = split[0].trim();
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The else case here means that value will be left simply as ,. Should it be explicitly set to null or empty string instead?

@tylerbenson tylerbenson mentioned this pull request Apr 7, 2020
@dougqh
Copy link
Copy Markdown
Contributor

dougqh commented Apr 7, 2020

Yes, I find that behavior of split surprising as well.

This change looks good to me. My biggest concern is whether we have other calls to String.split that also need to be fixed.

@tylerbenson tylerbenson merged commit 02555e5 into master Apr 9, 2020
@tylerbenson tylerbenson deleted the tyler/split-fix branch April 9, 2020 18:46
@tylerbenson tylerbenson added this to the 0.48.0 milestone Apr 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants