Lehel Boér created NIFI-9454:
--------------------------------
Summary: StandardFlowConfigurationDAO: FileUtils cannot rename
file while OutputStream is open
Key: NIFI-9454
URL: https://issues.apache.org/jira/browse/NIFI-9454
Project: Apache NiFi
Issue Type: Bug
Reporter: Lehel Boér
Assignee: Lehel Boér
When started NiFi on windows the following exception appeared in the logs and
NiFi didn't start.
{quote}{{org.apache.nifi.web.NiFiCoreException: Unable to start Flow
Controller.Caused by: java.io.IOException: Attempted 5 times but unable to
rename from '.\conf\flow.json.gz.temp.gz' to '.\conf\flow.json.gz'}}
{{at org.apache.nifi.util.file.FileUtils.renameFile(FileUtils.java:503)}}
{{at
org.apache.nifi.persistence.StandardFlowConfigurationDAO.saveFlow(StandardFlowConfigurationDAO.java:211)}}
{{at
org.apache.nifi.persistence.StandardFlowConfigurationDAO.saveJson(StandardFlowConfigurationDAO.java:193)}}
{{at
org.apache.nifi.persistence.StandardFlowConfigurationDAO.save(StandardFlowConfigurationDAO.java:187)}}
{{at
org.apache.nifi.persistence.StandardFlowConfigurationDAO.load(StandardFlowConfigurationDAO.java:114)}}
{{at
org.apache.nifi.controller.StandardFlowService.loadFromBytes(StandardFlowService.java:804)}}
{{at
org.apache.nifi.controller.StandardFlowService.load(StandardFlowService.java:533)}}
{{at
org.apache.nifi.web.contextlistener.ApplicationStartupContextListener.contextInitialized(ApplicationStartupContextListener.java:67)}}
{{... 38 common frames omitted}}
{quote}
{{In FileUtils I changed the Files::renameTo to Files::move as the Javadoc
suggested and I got the following exception:}}
{quote}{{Caused by: java.nio.file.FileSystemException:
.\conf\flow.json.gz.temp.gz -> .\conf\flow.json.gz: The process cannot access
the file because it is being used by another process.
at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:86)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
at sun.nio.fs.WindowsFileCopy.move(WindowsFileCopy.java:301)
at sun.nio.fs.WindowsFileSystemProvider.move(WindowsFileSystemProvider.java:287)
at java.nio.file.Files.move(Files.java:1395)
at org.apache.nifi.util.file.FileUtils.renameFile(FileUtils.java:496)
at
org.apache.nifi.persistence.StandardFlowConfigurationDAO.saveFlow(StandardFlowConfigurationDAO.java:211)
at
org.apache.nifi.persistence.StandardFlowConfigurationDAO.saveJson(StandardFlowConfigurationDAO.java:193)
at
org.apache.nifi.persistence.StandardFlowConfigurationDAO.save(StandardFlowConfigurationDAO.java:187)
at
org.apache.nifi.persistence.StandardFlowConfigurationDAO.load(StandardFlowConfigurationDAO.java:114)
at
org.apache.nifi.controller.StandardFlowService.loadFromBytes(StandardFlowService.java:804)
at
org.apache.nifi.controller.StandardFlowService.load(StandardFlowService.java:533)
at
org.apache.nifi.web.contextlistener.ApplicationStartupContextListener.contextInitialized(ApplicationStartupContextListener.java:67)
... 38 common frames omitted}}
{quote}
The file was solely being used by NiFi's java process, according to Windows'
Resource Monitor. [~markap14] pointed out that the outputstream in
StandardFlowConfigurationDAO is still open when the file is renamed. The issue
should be resolved by moving the renaming after closing the outputstream.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)