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? Commented Dec 22, 2014 at 12:48
  • Yes I am always storing in same name mid.odt and conversion is also same name. Commented 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.

Sign up to request clarification or add additional context in comments.

2 Comments

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.
Can we use the Synchronised method for this..Wheather this will work in web application...

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.