This service will be undergoing maintenance at 00:00 UTC, 2016-08-01. It is expected to last about 1 hours
Bug 876337 - Please fix FileUtils.move (Code enclosed)
Please fix FileUtils.move (Code enclosed)
Status: ON_QA
Product: JBoss Enterprise SOA Platform 5
Classification: JBoss
Component: JBossESB (Show other bugs)
5.3.0 GA
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: tcunning
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-11-13 16:20 EST by Rick Wagner
Modified: 2013-10-10 20:05 EDT (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
FileUtil.renameTo(..) returns true even if it fails to rename the file. As a result, when a file that is locked by another process is picked up by the SOA platform, and the rename fails, an error is logged even though the file is processed successfully on the next attempt (when the lock is gone).
Story Points: ---
Clone Of:
Environment:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)
Includes fixes. (8.88 KB, application/octet-stream)
2012-11-14 10:55 EST, Rick Wagner
no flags Details


External Trackers
Tracker ID Priority Status Summary Last Updated
JBoss Issue Tracker JBESB-3882 Major Closed FileUtils.renameTo should return false 2013-03-17 19:05:50 EDT

  None (edit)
Description Rick Wagner 2012-11-13 16:20:11 EST
when a file that is locked by another process is picked up by the SOA platform, and the rename fails, we get a error logg eventhough the file is processed successfully on the next attempt (when the lock is gone).
----
2012-05-31 08:43:56,694 DEBUG [org.jboss.soa.esb.util.FileUtil] (ESBScheduler:AnalytixImport.esb_Worker-0)   Unable to perform local rename of file 'c:\ipl\itg_kemlabsvar\inbox\D5V843AV.xml' to 'c:\ipl\itg_kemlabsvar\inbox\9f5d7a61-a564-483a-bea6-054331c640d0.D5V843AV.xml.9f5d7a61-a564-483a-bea6-054331c640d0'. Unable to move file.
2012-05-31 08:43:56,695 ERROR [org.jboss.soa.esb.listeners.gateway.AbstractFileGateway] (ESBScheduler:AnalytixImport.esb_Worker-0)   Composer <org.jboss.soa.esb.listeners.gateway.LocalFileMessageComposer> Failed.
org.jboss.soa.esb.listeners.message.MessageDeliverException: Invalid File payload.  File 'c:\ipl\itg_kemlabsvar\inbox\D5V843AV.xml.lck' doesn't exist.
----

The call chain here seems to be 
1) AbstractFileGateway.onSchedule()
2) AbstractFileGateway.setFileWorking(fileIn);
3) FileGatewayListener.renameFile(from,to);
4) FileUtil.renameTo(from, to)

The problem is that FileUtil.renameTo(..) returns true even if it fails to rename the file (in the step where it renames a localfile to a filename that includes the UUID).
This in turn makes setFileWorking(..) return a non-null value and AbstractFileGateway will go ahead and try to process the non-existing file.
Comment 1 Rick Wagner 2012-11-13 16:21:53 EST
Change set:

333,334c333
<         this.establishDeployedContentList(this.deploymentDir);
<         scan(true, deploymentOperations);
---
>             scan(true, deploymentOperations);
Comment 2 Rick Wagner 2012-11-14 10:55:08 EST
Created attachment 644973 [details]
Includes fixes.

Attached file includes fixes.
Comment 3 Rick Wagner 2012-11-14 10:56:24 EST
(In reply to comment #1)
> Change set:
> 
> 333,334c333
> <         this.establishDeployedContentList(this.deploymentDir);
> <         scan(true, deploymentOperations);
> ---
> >             scan(true, deploymentOperations);


---------------------------------------------------------------------------------

Please disregard comment 1.  The real changeset is below.

Thanks,

Rick


]0;rick@rwagner01:~/Junk/a/b[?1034h[rick@rwagner01 b]$ diff *old* *new*
113,114c113,114
<                 LOGGER.debug("Unable to perform local rename of file '" + from.getAbsolutePath() + "' to '" + fromLocalRename.getAbsolutePath() + "'.  Unable to move file.");
<                 return true;
---
>             LOGGER.debug("Unable to perform local rename of file '" + from.getAbsolutePath() + "' to '" + fromLocalRename.getAbsolutePath() + "'.  Unable to move file.");
>             return false;
120c120
<             return true;
---
>             return false;
131c131
<             return true;
---
>             return false;
209,213c209,213
<                     try
<                     {
<                             fos.close();
<                     }
<                     catch (final IOException ioe) {} // ignore
---
>                 try
>                 {
>                     fos.close();
>                 }
>                 catch (final IOException ioe) {} // ignore
220c220
<                     fis.close();
---
>                 fis.close();
238c238
<         while( (reader.read(chars)) > -1){
---
>         while( (reader.read(chars)) > -1) {
Comment 4 Rick Wagner 2012-11-14 10:57:38 EST
This BZ originated after fix BZ 829876 (on SOA-P 5.1).
Comment 5 David Boeren 2012-11-26 14:41:33 EST
The easiest way to test this I think is to write a test that opens a file in append mode (the goal is to have a file lock).

Then, while the file is open in append mode, call FileUtils.move() on it.
Comment 6 JBoss JIRA Server 2012-11-29 13:58:47 EST
Tom Cunningham <tcunning@redhat.com> updated the status of jira JBESB-3882 to Resolved
Comment 7 JBoss JIRA Server 2012-11-29 13:59:02 EST
Tom Cunningham <tcunning@redhat.com> updated the status of jira JBESB-3882 to Closed
Comment 8 tcunning 2012-11-29 14:01:15 EST
Reproduced this on Windows using David B's suggestion (see FileUtilUnitTest.test_renameTo).

Note You need to log in before you can comment on or make changes to this bug.