In my application, I have a scheduled task that keeps track of the directory for files with a specific extension. These files are processed further. There may be several processes running this application, and so that multiple instances process the same file, I change its extension, so it did not list another time using Files.movewith the option ATOMIC_MOVE. There are chances that several instances of the application will try to execute this method at the same time - my question is: what happens next? Should I expect any exceptions?
Files.move
ATOMIC_MOVE
: "", java.nio.file.NoSuchFileException, .
java.nio.file.NoSuchFileException
try { Files.move(previousPath, renamedPath, StandardCopyOption.ATOMIC_MOVE); } catch (NoSuchFileException e) { /* Another process has already processed that file. Ignore and move on. */ } catch (IOException e) { /* Must handle that one: something else has failed */ }
Linux macOS , , UUID . NoSuchFileException, .
NoSuchFileException
. , (NFS...), .
Source: https://habr.com/ru/post/1680076/More articles:Twilio query parameter for speech - pythonTypeScript 'props' property does not exist - typescriptUWP - Do not trigger the Click event when you press the spacebar (for example, in the "Movies and TV" application) - c #How to update real-time charts in HighCharts on iOS - gitДобавьте название и субтитры в навигационную панель, аналогичную Apple Music в IOS 11 - iosError of non-existent service since symfony 3.3 - phpC ++ - is it better to pass the enum class as a value or reference to const? - c ++warning defining a friend statement declared inside a namespace - c ++Vuejs configuration: using a global variable? - javascriptTrying to run Angular 4 without Node - angularAll Articles