Neil, Thanks for your useful feedback. I am still feeling my way as you can probably see from my earlier emails trying to setup a development environment.
I did actually think of this but didn't put it in scope for a couple of reasons. Firstly, the Tomcat documentation for readloadable quotes "Set to true if you want Catalina to monitor classes in /WEB-INF/classes/ and /WEB-INF/lib for changes, and automatically reload the web application if a change is detected. This feature is very useful during application development, but it requires significant runtime overhead and is not recommended for use on deployed production applications. That's why the default setting for this attribute is false. You can use the Manager web application, however, to trigger reloads of deployed applications on demand." Therefore, I took it to mean that this flag was geared at development, not production which is what I assume when you would deploy a .war file. So Tomcat would be listening to specific changes in .classes and .jar files that had just been compiled and these are normally small in size. But then I suppose that a single .jar file may be so sized that Tomcat could react while the file was still being written to the disk. Secondly, I sort of assumed that since the feature was already in place and handles changes to single files that this check for completeness has already been implemented, but then as I can't get a development environment to run, I don't have enough skills to drill into the sources without it being interactive to help me explore and learn. However, it makes sense that your recommendation is implemented, although I was imagining setting the delay to (say) 500ms to ensure that whatever IDE had time to complete the copying of all the files as that is a small price to pay for automatic refresh. Also by resetting the timer after each event it would have to be quite a large upload for Tomcat to start reacting. Like you, I am not sure how to formally check that a file has completed its copy to the destination. The most common suggestion I hear is to try and change its name and then change it back again and capture the exception which will be raised if the file is locked. I wonder whether attempting to set an attribute (e.g.toggle read-only) would have the same effect (i.e. only allow if file wasn't locked) and be a little more elegant. I would have to try it. I assume that Windows has a way of querying a file lock but not sure (a) whether that is exposed via a Java API and (b) whether that would apply to Unix as well (as I have only ever used Windows for development). > How does Tomcat test if a file has been updated? Again, I don't know this yet (lack of IDE again), but I assumed that it would be similar to the method I implemented in the attached source code, i.e. Create a listener for events being triggered on file changes to either /WEB-INF/classes/ and /WEB-INF/lib, as they are both hard-coded file paths. As an aside, I should have mentioned, for anyone interested in this thread and in case not obvious from the source, but to see the sample source code in action, you need to add, modify, rename or delete files within the specified directory in a File Explorer. John On Sun, 20 Feb 2022 at 00:04, Neil Aggarwal <n...@propfinancing.com> wrote: > > John: > > > If anyone has a moment, can you have a quick look and see if what I am > > proposing seems acceptable. > > Thinking about when a large file (Such as a war file) is being uploaded > to the server, we don't want Tomcat to reload it until after the file has > completed upload and is fully formed. > > How does Tomcat test if a file has been updated? > I assume it uses File.lastModified() or something similar. > > Does anyone know the detailed nuts and bolts of how that works? > Does last modified keep changing as the file is uploading or is it just > changed at the start of the upload? Is the behavior the same or different > across platforms? > > These questions should be taken into account when designing the solution. > > Thank you, > Neil > > -- > Neil Aggarwal, (972) 834-1565, http://www.propfinancing.com > We offer 30 year loans on single family houses! > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org