1

I have web application that generates the ODT file based on user request parameter and stored in the server as "mid.odt". After that it will be converted to Pdf and published to the user. Is there any synchronization issue will happen in here if more user will download the file with different parameter request.

2
  • 2
    are you always storing it with same name?
    – sidgate
    Dec 22, 2014 at 12:48
  • Yes I am always storing in same name mid.odt and conversion is also same name.
    – Rajiv
    Dec 22, 2014 at 14:26

1 Answer 1

2

Yes, there is a problem. If two different users are processing files at the same time, then both will create the same file, and only one of them will be processed. Possible outcomes are:

  1. one, or both of the users will fail
  2. both users will apparently succeed, but perhaps they will not get the PDF of the file they requested.
  3. other outcomes are also possible.

You should be creating each download in to a unique file. File.createTempFile() is an option you can use, or perhaps, in Java8, use Files.createTempFile(...).

You will need to communicate to the ODT/PDF conversion process what the new file name is.

2
  • Thanks for your answer. Can we synchronize so that only one user at a time may access to this functionality. It is designed in Scooter Framework (JSp) & Deployed in Apache tomcat server.
    – Rajiv
    Dec 24, 2014 at 10:15
  • Can we use the Synchronised method for this..Wheather this will work in web application...
    – Rajiv
    Dec 26, 2014 at 7:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.