Clone
Stefan Oehme
committed
on 04 Dec 17
Make UriTextResource#getFile cheaper
This method was checking whether the file exists,
which doesn't make sense, because it could only
happe… Show more
Make UriTextResource#getFile cheaper

This method was checking whether the file exists,

which doesn't make sense, because it could only

happen if a file URI was passed in the constructor.

If that file doesn't exist, then trying to read

content from the URI won't work either. We were

basically checking the existence twice - once when

calling getFile and another time when hashing it or

when trying to read from the URI instead. This made

the happy case unnecessarily slow without improving

failure behavior.

We now return the file unaltered and instead catch

the FileNotFoundException during hashing to provide

a nicer error message.

Show less

master + 407 more