Better error message if passing in invalid file path (e.g. because of not escaping cmdline args)

This commit is contained in:
Reinhard Pointner 2018-07-25 14:33:43 +07:00
parent 70f5565ddc
commit d33ada22c1
1 changed files with 5 additions and 0 deletions

View File

@ -156,6 +156,11 @@ public class License {
public static final MemoizedResource<License> INSTANCE = Resource.lazy(() -> parseLicenseFile(FILE.get()));
public static License importLicenseFile(File file) throws Exception {
// require non-empty license file
if (file.length() <= 0) {
throw new FileNotFoundException("License file not found: " + file);
}
// lock memoized resource while validating and setting a new license
synchronized (License.INSTANCE) {
// check if license file is valid and not expired