Skip to content

Conversation

@shoebox
Copy link

@shoebox shoebox commented Mar 27, 2019

It seems that in some cases the plugin is trying to resolve files who
are not part of the workspace, due to either their temporary nature, or
other IDE or tool file.

In my case, it was trying to resole files from the vim .undodir
directory, was failing to parse those files due to their binary nature,
and the whole sourceset resolution was failing in consequence.

To avoid that issue add a try catch around the file reading method to
ensure exception are not fired, and the resolution does not break.

It seems that in some cases the plugin is trying to resolve files who
are not part of the workspace, due to either their temporary nature, or
other IDE or tool file.

In my case, it was trying to resole files from the vim .undodir
directory, was failing to parse those files due to their binary nature,
and the whole sourceset resolution was failing in consequence.

To avoid that issue add a try catch around the file reading method to
ensure exception are not fired, and the resolution does not break.
@fwcd
Copy link
Owner

fwcd commented Mar 28, 2019

@shoebox Thank you for your contribution! I have left some notes below.

var content = ""

try {
content = Files.readAllLines(file).joinToString("\n")

Choose a reason for hiding this comment

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

It will be cleaner if you return from this line instead of saving the file contents to a variable

Copy link
Owner

Choose a reason for hiding this comment

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

Storing the contents in a variable is fine IMO. Since the string is going to be wrapped into a SourceVersion anyway, having two returns would entail some code duplication.

Raise the level of verbosing level in case of an exception while parsing
a source set file to `warn`.
Catch only IOException for now, being the issue we are encountering now.

That try/catch block can be removed, when the `.gitignore` file content
is taken into account.
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.

4 participants