Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 364502 - Jetty Server does not notice file symlink changes
Summary: Jetty Server does not notice file symlink changes
Status: CLOSED FIXED
Alias: None
Product: Jetty
Classification: RT
Component: server (show other bugs)
Version: 7.5.4   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 9.0.x   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-22 13:25 EST by Elliott Clark CLA
Modified: 2016-02-16 16:32 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Elliott Clark CLA 2011-11-22 13:25:12 EST
Build Identifier: 7.5.4.v20111024

on linux I have a context serving /static from /opt/foo/current.

/opt/foo/current is a symlink to /opt/foo/2011010101

When a file from /static is requested it is cached in the server.

Now if I switch the /opt/foo/current link to point to /opt/foo/2011020202.  Where the contents of the files are different from what was in /opt/foo/2011010101 Jetty continues to serve the old content until the server is restarted.

This  method of linking statics is a good way to get atomic deploys of statics.

Reproducible: Always

Steps to Reproduce:
1. Create symlink /opt/foo/current pointing to a directory /opt/foo/bar
2. Create a Context serving /static from /opt/foo/current
3. Get a file from /static
4. Move the symlink /opt/fooo/current to /opt/foo/baz
5. Get the same file as in step 3.  Notice it is the old file.
Comment 1 Elliott Clark CLA 2011-11-22 13:29:39 EST
Context: https://gist.github.com/1384384
repo: https://gist.github.com/1384391
Comment 2 Greg Wilkins CLA 2011-11-27 23:03:56 EST
The issue is that on unix, links are resolved when a File Descriptor is obtained, thus changing a symlink to a directory does not make any change at all to the File Descriptor held by the jetty file cache, thus no change is noticed.

It might be possible to add a watch file to the cache, that could be set to be the symlink itself. If the watch file changes, the entire resource cache can be flushed.

Alternately, a cache flush could be scheduled every few seconds, which would not have a huge impact on scalability, but would help development mode.
Comment 3 Jesse McConnell CLA 2013-01-30 11:01:00 EST
bumping this up to jetty9 to be fixed, since java 7 is in play which has support for symbolic links we should be able to resolve this reasonable
Comment 4 Jesse McConnell CLA 2016-02-16 16:32:37 EST
reasonably sure this was resolved ages ago