Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 364502

Summary: Jetty Server does not notice file symlink changes
Product: [RT] Jetty Reporter: Elliott Clark <eclark84>
Component: serverAssignee: Project Inbox <jetty-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: eclark84, jesse.mcconnell, jetty-inbox
Version: 7.5.4   
Target Milestone: 9.0.x   
Hardware: PC   
OS: Linux   
Whiteboard:

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