Skip to content

Instantly share code, notes, and snippets.

@Groostav
Last active October 18, 2019 19:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Groostav/aeca10852859b0f79f679f0e713361cb to your computer and use it in GitHub Desktop.
Save Groostav/aeca10852859b0f79f679f0e713361cb to your computer and use it in GitHub Desktop.
Caused by: java.nio.file.NoSuchFileException: C:\Users\Inhal\AppData\Roaming\OASIS 2020.1\licenses\trial-license.l4j
at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:79)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102)
at sun.nio.fs.WindowsFileAttributeViews$Basic.readAttributes(WindowsFileAttributeViews.java:53)
at sun.nio.fs.WindowsFileAttributeViews$Basic.readAttributes(WindowsFileAttributeViews.java:38)
at sun.nio.fs.WindowsFileSystemProvider.readAttributes(WindowsFileSystemProvider.java:193)
at java.nio.file.Files.readAttributes(Files.java:1737)
at java.nio.file.Files.size(Files.java:2332)
at com.empowerops.front_end.LicenseImportingServiceImpl$findLicenseCacheSources$2.invokeSuspend(LicenseImportingService.kt:142)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:241)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:594)
at kotlinx.coroutines.scheduling.CoroutineScheduler.access$runSafely(CoroutineScheduler.kt:60)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:740)
//saw this insanity from jvm + windows when easton was testing:
// somePath.isReadableFile && Files.size(somePath) < X
// threw an exception, because the file was readable, but its metadata was not readable.
// so Files.size threw. Rediculous. Files suck.
// see the first exception in #2554: https://github.com/EmpowerOperations/OASIS/issues/2554#issuecomment-543897459
fun Path.fileSizeOrNull(): Long? {
val attributes = try { readAttributes(this, BasicFileAttributes::class.java) }
catch (ex: IOException) { Log.info("failed to read 'BasicFileAttributes' on file $this"); null }
// WindowsFileAttributes is a strangely encoded (this windows bit twiddling) POJO
// so none of its members throw, thus accessing `size()` here isnt a disk IO operation,
return attributes?.size()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment