Skip to content

Fix crashing on empty - #474

Merged
nedtwigg merged 5 commits into
diffplug:masterfrom
MarkRyanDev:fix_crashing_on_empty
Oct 17, 2019
Merged

nedtwigg merged 5 commits into
diffplug:masterfrom
MarkRyanDev:fix_crashing_on_empty

Conversation

@MarkRyanDev

Copy link
Copy Markdown
Contributor

Fixes #305

ImportSorter no longer blows up if you give it an empty file.

@nedtwigg nedtwigg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks! Your fix does a good job at the site of the stacktrace, but it seems easier to just say at the beginning of the function if (input.isEmpty()) { return input; }. That way all the code below that can take as a precondition "this string has length > 0". That's more robust than having to check for it at every point.

Also, update your changelog entry so that it points to this PR.

Thanks for the PR!

@nedtwigg
nedtwigg merged commit 61a7277 into diffplug:master Oct 17, 2019
@nedtwigg

Copy link
Copy Markdown
Member

Thanks again!

@nedtwigg

Copy link
Copy Markdown
Member

Released in x.26.0

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.

StringIndexOutOfBoundsException for empty Groovy file when performing importOrder

2 participants