Cheshar
Cheshar

Reputation: 587

setLastModified not working on an NFS share

I have an NFS share mounted on one of my Solaris server. The path /appdata/anp is mounted from Server A onto Server B. Under the share:

/appdata/anp

I have a folder named

/appdata/anp/factory

In the above directory I put files which has the data that needs to imported/updated in the database. After importing data in the database I move the file to success/failure directory based on the operation result of the imported data.

/appdata/anp/factory/success

/appdata/anp/factory/failure

I move the file to either of the above directories and update the last modified time of the file to the current system time using:

file.setLastModified

which returns a boolean value. The problem is whenever I am doing this update operation it fails to update the timestamp of that file to the current system time.

Does anyone know what are the the scenarios in which

file.setLastModified

returns failure. I have even checked the NFS permissions and everything seems okay to me. Is there anyway to know the cases where setLastModified could return failure?

Please help me out I am really pulling my hair on this one!! :(

Upvotes: 0

Views: 1502

Answers (1)

Lance
Lance

Reputation: 11

I had a similar problem on a Unix file system. In my case it was because unix was truncating the last modified milliseconds and setting the last modified to:

System.currentTimeMillis() - System.currentTimeMillis() % 1000

It was affecting a test case which was manipulating a file then checking for updates via file.lastModified(). I simply added Thread.sleep(1100) before updating the file in my test case and all was resolved.

Hope that helps the next person.

Upvotes: 1

Related Questions