Execute plugins from a copy in $site_path/tmp

When starting a plugin its JAR is copied to a unique name in
$site_path/tmp. This avoids race conditions with administrators
installing a new version of a plugin while the JVM is still using
it to handle user current activities.

The temporary file copies are automatically deleted by the server only
after the URLClassLoader that wraps it has been reclaimed by the JVM
GC. By waiting until GC we can ensure the JAR exists on disk as long
as running code might need to use it.

Change-Id: I8e211592f8901bf44d66885409db4f7d6aaaaad3
This commit is contained in:
Shawn O. Pearce
2012-05-09 14:14:56 -07:00
parent a576cc8479
commit 67f7952621
6 changed files with 130 additions and 29 deletions

View File

@@ -67,6 +67,7 @@ public class SitePathInitializer {
mkdir(site.bin_dir);
mkdir(site.etc_dir);
mkdir(site.lib_dir);
mkdir(site.tmp_dir);
mkdir(site.logs_dir);
mkdir(site.mail_dir);
mkdir(site.static_dir);
@@ -85,6 +86,7 @@ public class SitePathInitializer {
extract(site.gerrit_sh, Init.class, "gerrit.sh");
chmod(0755, site.gerrit_sh);
chmod(0700, site.tmp_dir);
extractMailExample("Abandoned.vm");
extractMailExample("ChangeFooter.vm");