Merge pull request #2843 from eclipse/jetty-9.4.x-issue-2835-war-file-locking-windows

Issue #2835 - Use original WAR Resource for lastModified
This commit is contained in:
Joakim Erdfelt 2018-08-22 09:06:33 -05:00 committed by GitHub
commit e93dc59e10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 4 deletions

View File

@ -24,8 +24,6 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@ -582,6 +580,13 @@ public class WebInfConfiguration extends AbstractConfiguration
if (LOG.isDebugEnabled())
LOG.debug("Try webapp=" + web_app + ", exists=" + web_app.exists() + ", directory=" + web_app.isDirectory()+" file="+(web_app.getFile()));
// Track the original web_app Resource, as this could be a PathResource.
// Later steps force the Resource to be a JarFileResource, which introduces
// URLConnection caches in such a way that it prevents Hot Redeployment
// on MS Windows.
Resource originalWarResource = web_app;
// Is the WAR usable directly?
if (web_app.exists() && !web_app.isDirectory() && !web_app.toString().startsWith("jar:"))
{
@ -642,8 +647,9 @@ public class WebInfConfiguration extends AbstractConfiguration
}
else
{
//only extract if the war file is newer, or a .extract_lock file is left behind meaning a possible partial extraction
if (web_app.lastModified() > extractedWebAppDir.lastModified() || extractionLock.exists())
// Only extract if the war file is newer, or a .extract_lock file is left behind meaning a possible partial extraction
// Use the original War Resource to obtain lastModified to avoid filesystem locks on MS Windows.
if (originalWarResource.lastModified() > extractedWebAppDir.lastModified() || extractionLock.exists())
{
extractionLock.createNewFile();
IO.delete(extractedWebAppDir);