Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename strategy filesystem exception #8335

Merged
merged 2 commits into from Sep 9, 2022
Merged

Rename strategy filesystem exception #8335

merged 2 commits into from Sep 9, 2022

Conversation

CZuegner
Copy link
Contributor

@CZuegner CZuegner commented Sep 9, 2022

No description provided.

Windows Environment throws FileSystemException when the file is blocked by another process
@github-actions
Copy link
Contributor

github-actions bot commented Sep 9, 2022

⚠️ This PR changes Camel components and will be tested automatically.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 9, 2022

✔️ Finished component verification: 0 component(s) test failed out of 1 component(s) tested

@davsclaus
Copy link
Contributor

Are you able to provide the stacktrace from windows you see when the file does not exists ?

@CZuegner
Copy link
Contributor Author

CZuegner commented Sep 9, 2022

My testcase is to use readlock=rename strategy.

Stacktrace when file is blocked by another process:

2022-09-09 11:51:19,050 WARN  [org.apa.cam.com.fil.FileConsumer] (Camel (camel-9) thread #9 - file://c:%5Ctemp%5Cinput) file://c:%5Ctemp%5Cinput?delay=1000&move=c%3A%5Ctemp%5Csave%2F%24%7Bfile%3Aname%7D&moveFailed=c%3A%5Ctemp%5Cerror%2F%24%7Bfile%3Aname%7D cannot begin processing file: GenericFile[c:\temp\input\test.txt] due to: Error renaming file from c:\temp\input\test.txt to c:\temp\input\test.txt.camelExclusiveReadLock. Caused by: [org.apache.camel.component.file.GenericFileOperationFailedException - Error renaming file from c:\temp\input\test.txt to c:\temp\input\test.txt.camelExclusiveReadLock]: org.apache.camel.component.file.GenericFileOperationFailedException: Error renaming file from c:\temp\input\test.txt to c:\temp\input\test.txt.camelExclusiveReadLock
	at org.apache.camel.component.file.FileOperations.renameFile(FileOperations.java:93)
	at org.apache.camel.component.file.strategy.GenericFileRenameExclusiveReadLockStrategy.acquireExclusiveReadLock(GenericFileRenameExclusiveReadLockStrategy.java:80)
	at org.apache.camel.component.file.strategy.FileRenameExclusiveReadLockStrategy.acquireExclusiveReadLock(FileRenameExclusiveReadLockStrategy.java:49)
	at org.apache.camel.component.file.strategy.GenericFileProcessStrategySupport.begin(GenericFileProcessStrategySupport.java:72)
	at org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy.begin(GenericFileRenameProcessStrategy.java:39)
	at com.osramos.dsimaptransfer.util.MoveInvalidProcessingStrategy.begin(MoveInvalidProcessingStrategy.java:39)
	at org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:388)
	at org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:245)
	at org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:206)
	at org.apache.camel.support.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:202)
	at org.apache.camel.support.ScheduledPollConsumer.run(ScheduledPollConsumer.java:116)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.nio.file.FileSystemException: c:\temp\input\test.txt -> c:\temp\input\test.txt.camelExclusiveReadLock: The process cannot access the file because it is being used by another process.

	at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:92)
	at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
	at java.base/sun.nio.fs.WindowsFileCopy.copy(WindowsFileCopy.java:202)
	at java.base/sun.nio.fs.WindowsFileSystemProvider.copy(WindowsFileSystemProvider.java:283)
	at java.base/java.nio.file.Files.copy(Files.java:1295)
	at org.apache.camel.util.FileUtil.copyFile(FileUtil.java:480)
	at org.apache.camel.util.FileUtil.renameFileUsingCopy(FileUtil.java:462)
	at org.apache.camel.util.FileUtil.renameFile(FileUtil.java:436)
	at org.apache.camel.component.file.FileOperations.renameFile(FileOperations.java:90)
	... 16 more

@davsclaus
Copy link
Contributor

Lets make it broader and catch IOException then its all file related errors

@davsclaus davsclaus merged commit eff77c0 into apache:main Sep 9, 2022
@davsclaus
Copy link
Contributor

davsclaus pushed a commit that referenced this pull request Sep 9, 2022
Windows Environment throws FileSystemException when the file is blocked by another process
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants