diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-04-24 09:15:05 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-05-11 10:21:55 +0200 |
commit | 14a5c982e5f1b28354a853073bd3e225b3914abe (patch) | |
tree | e298a2948f49628880f8d5290451adc14a920613 /sonar-home/src/main/java | |
parent | cba928d505985972e13c8e895b490a52702af925 (diff) | |
download | sonarqube-14a5c982e5f1b28354a853073bd3e225b3914abe.tar.gz sonarqube-14a5c982e5f1b28354a853073bd3e225b3914abe.zip |
SONAR-6370 isolate plugin classloader from core
Diffstat (limited to 'sonar-home/src/main/java')
-rw-r--r-- | sonar-home/src/main/java/org/sonar/home/cache/FileCache.java | 44 |
1 files changed, 1 insertions, 43 deletions
diff --git a/sonar-home/src/main/java/org/sonar/home/cache/FileCache.java b/sonar-home/src/main/java/org/sonar/home/cache/FileCache.java index 3588a908b4b..63a1168639d 100644 --- a/sonar-home/src/main/java/org/sonar/home/cache/FileCache.java +++ b/sonar-home/src/main/java/org/sonar/home/cache/FileCache.java @@ -20,15 +20,12 @@ package org.sonar.home.cache; import org.apache.commons.io.FileUtils; -import org.sonar.api.utils.ZipUtils; import org.sonar.home.log.Log; import javax.annotation.CheckForNull; import java.io.File; -import java.io.FileOutputStream; import java.io.IOException; -import java.util.zip.ZipEntry; /** * This class is responsible for managing Sonar batch file cache. You can put file into cache and @@ -138,7 +135,7 @@ public class FileCache { } } - private File createTempDir() { + public File createTempDir() { String baseName = System.currentTimeMillis() + "-"; for (int counter = 0; counter < TEMP_DIR_ATTEMPTS; counter++) { @@ -161,43 +158,4 @@ public class FileCache { } return dir; } - - /** - * Unzip a cached file. Unzip is done only the first time. - * @param cachedFile - * @return directory where cachedFile was unzipped - * @throws IOException - */ - public File unzip(File cachedFile) throws IOException { - String filename = cachedFile.getName(); - File destDir = new File(cachedFile.getParentFile(), filename + "_unzip"); - File lockFile = new File(cachedFile.getParentFile(), filename + "_unzip.lock"); - if (!destDir.exists()) { - FileOutputStream out = new FileOutputStream(lockFile); - try { - java.nio.channels.FileLock lock = out.getChannel().lock(); - try { - // Recheck in case of concurrent processes - if (!destDir.exists()) { - File tempDir = createTempDir(); - ZipUtils.unzip(cachedFile, tempDir, new LibFilter()); - FileUtils.moveDirectory(tempDir, destDir); - } - } finally { - lock.release(); - } - } finally { - out.close(); - FileUtils.deleteQuietly(lockFile); - } - } - return destDir; - } - - private static final class LibFilter implements ZipUtils.ZipEntryFilter { - @Override - public boolean accept(ZipEntry entry) { - return entry.getName().startsWith("META-INF/lib"); - } - } } |