Menu

#3 automove locks the files

open
nobody
None
5
2007-10-16
2007-10-16
julien
No

Hi,
I use setAutoMoveDirectory(File dirIn, File dirOut) method. When I receive a file f1 in dirIn, it brings it to dirOut, but f1 cannot then be deleted before "a certain amount of time" as it is certainly locked by the jpoller. How is that? And how can I go around this please?
Regards,
Julien

Discussion

  • julien

    julien - 2007-10-17

    Logged In: YES
    user_id=1914476
    Originator: YES

    To be more complete :
    I use Java 1.5.0_11 on Win XP

    I saw that the problem was already raised and apparently solved the issue, but I did the change myself (adding the line "raf.close()"), compiled the JPoller with Java 1.4.2_05 and still compiled the project that uses JPoller with Java 1.5.0_11 and I still have exactly the same problem. I have to set up a timer that retries to delete the file, and after a few attempts it finally succeeds...

     
  • julien

    julien - 2007-10-17

    Logged In: YES
    user_id=1914476
    Originator: YES

    To be more complete :
    I use Java 1.5.0_11 on Win XP

    I saw that the problem was already raised and apparently solved the issue, but I did the change myself (adding the line "raf.close()"), compiled the JPoller with Java 1.4.2_05 and still compiled the project that uses JPoller with Java 1.5.0_11 and I still have exactly the same problem. I have to set up a timer that retries to delete the file, and after a few attempts it finally succeeds...

     
  • julien

    julien - 2007-10-17

    Logged In: YES
    user_id=1914476
    Originator: YES

    To be more complete :
    I use Java 1.5.0_11 on Win XP

    I saw that the problem was already raised and apparently solved the issue, but I did the change myself (adding the line "raf.close()"), compiled the JPoller with Java 1.4.2_05 and still compiled the project that uses JPoller with Java 1.5.0_11 and I still have exactly the same problem. I have to set up a timer that retries to delete the file, and after a few attempts it finally succeeds...

     
  • Cristiano Sadun

    Cristiano Sadun - 2008-03-05

    Logged In: YES
    user_id=15880
    Originator: NO

    Hei,

    thanks for your comment. Automove in JPoller is at the moment implemented simply as a renameTo() operation on a File object. JDK1.4 stated simply that the operation might fail (JPoller will raise an AutomoveException in case it does fail). From JDK1.5 documentation on, Sun added that the operation is platform-dependent and not necessarily atomic, which may explain the behavior you experience. Alternatives are verifying the locked state of the file post-automove and delay the notification until the os unlocks it; to implement the move as copy+delete, which would degrade performance noticeably; provide the timer functionality you talk about "out of the boks" with a base implementation for pollmanagers. These would be useful enhancements, I'll try to look into it.

     
  • Cristiano Sadun

    Cristiano Sadun - 2008-03-05

    Logged In: YES
    user_id=15880
    Originator: NO

    Do you have the bypasslockedfile feature on?

     

Log in to post a comment.