[ 
https://issues.apache.org/jira/browse/NIFI-9454?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17455922#comment-17455922
 ] 

ASF subversion and git services commented on NIFI-9454:
-------------------------------------------------------

Commit bf288f3ba1e95dad6b16457079208c6f25fa31be in nifi's branch 
refs/heads/main from Lehel Boér
[ https://gitbox.apache.org/repos/asf?p=nifi.git;h=bf288f3 ]

NIFI-9454: Moved file renaming after closing the OutputStream in 
StandardFlowConfigurationDAO (#5581)



> 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
>            Priority: Major
>             Fix For: 1.16.0
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> 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)

Reply via email to