Mercurial > hg > release > icedtea-web-1.7
changeset 1196:03e42ec1bc49
Cache now uses PathsAndFiles instances instead of various duplications
line wrap: on
line diff
--- a/ChangeLog Thu Apr 09 11:31:31 2015 -0400 +++ b/ChangeLog Fri Apr 10 12:47:01 2015 +0200 @@ -1,3 +1,38 @@ +2015-04-10 Jiri Vanek <jvanek@redhat.com> + + Cache now uses PathsAndFiles instances instead of various duplications + * netx/net/sourceforge/jnlp/cache/CacheLRUWrapper.java: using InfrastructureFileDescriptor + instead of copied Files. Same with recentlyUsedPropertiesFile. Both made final privat + and accessible only via getter. (getRecentlyUsedPropertiesFile) redesigned, to use cached + PropertiesFile. If underlying InfrastructureFileDescriptor changes, the cached + PropertiesFile is closed and new created and returned. + * netx/net/sourceforge/jnlp/cache/CacheUtil.java: Are using getters from + CacheLRUWrapper singleton to atomic approach. Not storing those values anymore. + * netx/net/sourceforge/jnlp/config/InfrastructureFileDescriptor.java: Moved out + from inner class in PathsAndFiles + * netx/net/sourceforge/jnlp/config/PathsAndFiles.java:Lost InfrastructureFileDescriptor + in favour of outer one. + * netx/net/sourceforge/jnlp/controlpanel/AdvancedProxySettingsDialog.java: config + made final + * netx/net/sourceforge/jnlp/controlpanel/AdvancedProxySettingsPane.java: same + * netx/net/sourceforge/jnlp/controlpanel/DesktopShortcutPanel.java: same + * netx/net/sourceforge/jnlp/controlpanel/JVMPanel.java: same + * netx/net/sourceforge/jnlp/controlpanel/SecuritySettingsPanel.java: same + * netx/net/sourceforge/jnlp/controlpanel/CacheViewer.java: removed config + * netx/net/sourceforge/jnlp/controlpanel/TemporaryInternetFilesPanel.java: adapted to above + * netx/net/sourceforge/jnlp/runtime/JNLPProxySelector.java: moved to diamond + * netx/net/sourceforge/jnlp/security/KeyStores.java: adapted to InfrastructureFileDescriptor + * netx/net/sourceforge/jnlp/util/docprovider/ItwebSettingsTextsProvider.java: same + * netx/net/sourceforge/jnlp/util/docprovider/TextsProvider.java: same + * sun/applet/PluginProxySelector.java: same + * tests/netx/unit/net/sourceforge/jnlp/security/KeyStoresTest.java: same + * tests/test-extensions/net/sourceforge/jnlp/tools/DeploymentPropetiesModifier.java: + same + * tests/netx/unit/net/sourceforge/jnlp/cache/CacheLRUWrapperTest.java: is now + using dummy InfrastructureFileDescriptor to allow fake CacheLRUWrapper tests + * tests/netx/unit/net/sourceforge/jnlp/controlpanel/CommandLineTest.java: small + fixes to unlcear strings + 2015-04-09 Lukasz Dracz <ldracz@redhat.com> fix lines displayed in javaws help
--- a/netx/net/sourceforge/jnlp/cache/CacheLRUWrapper.java Thu Apr 09 11:31:31 2015 -0400 +++ b/netx/net/sourceforge/jnlp/cache/CacheLRUWrapper.java Fri Apr 10 12:47:01 2015 +0200 @@ -48,6 +48,7 @@ import java.util.List; import java.util.Map.Entry; import java.util.Set; +import net.sourceforge.jnlp.config.InfrastructureFileDescriptor; import net.sourceforge.jnlp.config.PathsAndFiles; import net.sourceforge.jnlp.util.FileUtils; @@ -67,11 +68,11 @@ * accessed) followed by folder of item. value = path to file. */ - private final PropertiesFile recentlyUsedPropertiesFile; - private final File cacheDir; + private final InfrastructureFileDescriptor recentlyUsedPropertiesFile; + private final InfrastructureFileDescriptor cacheDir; public CacheLRUWrapper() { - this(PathsAndFiles.getRecentlyUsedFile().getFile(), PathsAndFiles.CACHE_DIR.getFile()); + this(PathsAndFiles.getRecentlyUsedFile(), PathsAndFiles.CACHE_DIR); } @@ -80,13 +81,13 @@ * @param recentlyUsed file to be used as recently_used file * @param cacheDir dir with cache */ - public CacheLRUWrapper(final File recentlyUsed, final File cacheDir) { - recentlyUsedPropertiesFile = new PropertiesFile(recentlyUsed); + public CacheLRUWrapper(final InfrastructureFileDescriptor recentlyUsed, final InfrastructureFileDescriptor cacheDir) { + recentlyUsedPropertiesFile = recentlyUsed; this.cacheDir = cacheDir; - if (!recentlyUsed.exists()) { + if (!recentlyUsed.getFile().exists()) { try { - FileUtils.createParentDir(recentlyUsed); - FileUtils.createRestrictedFile(recentlyUsed, true); + FileUtils.createParentDir(recentlyUsed.getFile()); + FileUtils.createRestrictedFile(recentlyUsed.getFile(), true); } catch (IOException e) { OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e); } @@ -102,25 +103,44 @@ return CacheLRUWrapperHolder.INSTANCE; } + + private PropertiesFile cachedRecentlyUsedPropertiesFile = null ; /** * @return the recentlyUsedPropertiesFile */ - public PropertiesFile getRecentlyUsedPropertiesFile() { - return recentlyUsedPropertiesFile; + synchronized PropertiesFile getRecentlyUsedPropertiesFile() { + if (cachedRecentlyUsedPropertiesFile == null) { + //no properties file yet, create it + cachedRecentlyUsedPropertiesFile = new PropertiesFile(recentlyUsedPropertiesFile.getFile()); + return cachedRecentlyUsedPropertiesFile; + } + if (recentlyUsedPropertiesFile.getFile().equals(cachedRecentlyUsedPropertiesFile.getStoreFile())){ + //The underlying InfrastructureFileDescriptor is still pointing to the same file, use current properties file + return cachedRecentlyUsedPropertiesFile; + } else { + //the InfrastructureFileDescriptor was set to different location, move to it + if (cachedRecentlyUsedPropertiesFile.tryLock()) { + cachedRecentlyUsedPropertiesFile.store(); + cachedRecentlyUsedPropertiesFile.unlock(); + } + cachedRecentlyUsedPropertiesFile = new PropertiesFile(recentlyUsedPropertiesFile.getFile()); + return cachedRecentlyUsedPropertiesFile; + } + } /** * @return the cacheDir */ - public File getCacheDir() { + public InfrastructureFileDescriptor getCacheDir() { return cacheDir; } /** * @return the recentlyUsedFile */ - public File getRecentlyUsedFile() { - return recentlyUsedPropertiesFile.getStoreFile(); + public InfrastructureFileDescriptor getRecentlyUsedFile() { + return recentlyUsedPropertiesFile; } private static class CacheLRUWrapperHolder{ @@ -170,7 +190,7 @@ // 2. check path format - does the path look correct? if (path != null) { - if (!path.contains(getCacheDir().getAbsolutePath())) { + if (!path.contains(getCacheDir().getFullPath())) { it.remove(); modified = true; } @@ -185,6 +205,7 @@ /** * Write file to disk. + * @return true if properties were successfully stored, false otherwise */ public synchronized boolean store() { if (getRecentlyUsedPropertiesFile().isHeldByCurrentThread()) { @@ -202,10 +223,11 @@ * @return true if we successfully added to map, false otherwise. */ public synchronized boolean addEntry(String key, String path) { - if (getRecentlyUsedPropertiesFile().containsKey(key)) { + PropertiesFile props = getRecentlyUsedPropertiesFile(); + if (props.containsKey(key)) { return false; } - getRecentlyUsedPropertiesFile().setProperty(key, path); + props.setProperty(key, path); return true; } @@ -216,15 +238,16 @@ * @return true if we successfully removed key from map, false otherwise. */ public synchronized boolean removeEntry(String key) { - if (!recentlyUsedPropertiesFile.containsKey(key)) { + PropertiesFile props = getRecentlyUsedPropertiesFile(); + if (!props.containsKey(key)) { return false; } - getRecentlyUsedPropertiesFile().remove(key); + props.remove(key); return true; } private String getIdForCacheFolder(String folder) { - int len = getCacheDir().getAbsolutePath().length(); + int len = getCacheDir().getFullPath().length(); int index = folder.indexOf(File.separatorChar, len + 1); return folder.substring(len + 1, index); } @@ -236,12 +259,15 @@ * @return true if we successfully updated value, false otherwise. */ public synchronized boolean updateEntry(String oldKey) { - if (!recentlyUsedPropertiesFile.containsKey(oldKey)) return false; - String value = getRecentlyUsedPropertiesFile().getProperty(oldKey); + PropertiesFile props = getRecentlyUsedPropertiesFile(); + if (!props.containsKey(oldKey)) { + return false; + } + String value = props.getProperty(oldKey); String folder = getIdForCacheFolder(value); - getRecentlyUsedPropertiesFile().remove(oldKey); - getRecentlyUsedPropertiesFile().setProperty(Long.toString(System.currentTimeMillis()) + "," + folder, value); + props.remove(oldKey); + props.setProperty(Long.toString(System.currentTimeMillis()) + "," + folder, value); return true; } @@ -257,7 +283,7 @@ List<Entry<String, String>> entries = new ArrayList<>(); for (Entry e : getRecentlyUsedPropertiesFile().entrySet()) { - entries.add(new AbstractMap.SimpleImmutableEntry<String, String>(e)); + entries.add(new AbstractMap.SimpleImmutableEntry<>(e)); } // sort by keys in descending order.
--- a/netx/net/sourceforge/jnlp/cache/CacheUtil.java Thu Apr 09 11:31:31 2015 -0400 +++ b/netx/net/sourceforge/jnlp/cache/CacheUtil.java Fri Apr 10 12:47:01 2015 +0200 @@ -145,7 +145,7 @@ } CacheLRUWrapper lruHandler = CacheLRUWrapper.getInstance(); - File cacheDir = lruHandler.getCacheDir(); + File cacheDir = lruHandler.getCacheDir().getFile(); if (!(cacheDir.isDirectory())) { return false; } @@ -342,7 +342,7 @@ * Get the path to file minus the cache directory and indexed folder. */ private static String pathToURLPath(String path) { - int len = CacheLRUWrapper.getInstance().getCacheDir().getAbsolutePath().length(); + int len = CacheLRUWrapper.getInstance().getCacheDir().getFullPath().length(); int index = path.indexOf(File.separatorChar, len + 1); return path.substring(index); } @@ -354,7 +354,7 @@ public static String getCacheParentDirectory(String filePath) { String path = filePath; String tempPath = ""; - String cacheDir = CacheLRUWrapper.getInstance().getCacheDir().getAbsolutePath(); + String cacheDir = CacheLRUWrapper.getInstance().getCacheDir().getFullPath(); while(path.startsWith(cacheDir) && !path.equals(cacheDir)){ tempPath = new File(path).getParent(); @@ -384,7 +384,7 @@ lruHandler.lock(); lruHandler.load(); for (long i = 0; i < Long.MAX_VALUE; i++) { - String path = lruHandler.getCacheDir().getAbsolutePath() + File.separator + i; + String path = lruHandler.getCacheDir().getFullPath()+ File.separator + i; File cDir = new File(path); if (!cDir.exists()) { // We can use this directory. @@ -591,8 +591,8 @@ * rStr first becomes: /0/http/www.example.com/subdir/a.jar * then rstr becomes: /home/user1/.icedtea/cache/0 */ - String rStr = file.getPath().substring(lruHandler.getCacheDir().getAbsolutePath().length()); - rStr =lruHandler.getCacheDir().getAbsolutePath() + rStr.substring(0, rStr.indexOf(File.separatorChar, 1)); + String rStr = file.getPath().substring(lruHandler.getCacheDir().getFullPath().length()); + rStr = lruHandler.getCacheDir().getFullPath()+ rStr.substring(0, rStr.indexOf(File.separatorChar, 1)); long len = file.length(); if (keep.contains(file.getPath().substring(rStr.length()))) {
--- a/netx/net/sourceforge/jnlp/config/PathsAndFiles.java Thu Apr 09 11:31:31 2015 -0400 +++ b/netx/net/sourceforge/jnlp/config/PathsAndFiles.java Fri Apr 10 12:47:01 2015 +0200 @@ -290,7 +290,7 @@ }; public static final InfrastructureFileDescriptor USER_DEPLOYMENT_FILE = new ItwConfigFileDescriptor(DEPLOYMENT_PROPERTIES, "FILEuserdp", Target.JAVAWS, Target.ITWEB_SETTINGS); - private static enum Target { + static enum Target { JAVAWS, PLUGIN, ITWEB_SETTINGS, POLICY_EDITOR; } @@ -338,132 +338,6 @@ return getAllFiles(Target.PLUGIN); } - public static class InfrastructureFileDescriptor { - - private final String fileName; - private final String pathStub; - private final String systemPathStub; - private final String descriptionKey; - private final Target[] target; - - private InfrastructureFileDescriptor(String fileName, String pathStub, String systemPathStub, String descriptionKey, Target... target) { - this.fileName = fileName; - this.pathStub = pathStub; - this.systemPathStub = systemPathStub; - this.descriptionKey = descriptionKey; - this.target = target; - } - - /** setup-able files have to override this - * if they don't, they are read only, and set value will fail - * if it is desired to write value of property, then override and use known key. - * @return null by default. Should return key to configuration if overriden. - */ - protected String getPropertiesKey() { - return null; - } - - public File getFile() { - return new File(getFullPath()); - } - - public void setValue(String value) { - String key = getPropertiesKey(); - if (key == null) { - throw new IllegalStateException("This file is read only"); - } else { - JNLPRuntime.getConfiguration().setProperty(key, value); - } - } - - public String getFullPath() { - String key = getPropertiesKey(); - if (key == null) { - return getDefaultFullPath(); - } else { - return JNLPRuntime.getConfiguration().getProperty(key); - } - } - - public File getDefaultFile() { - return new File(getDefaultFullPath()); - } - - public String getDefaultDir() { - return clean(systemPathStub + File.separator + pathStub); - } - - public String getDefaultFullPath() { - return clean(systemPathStub + File.separator + pathStub + File.separator + fileName); - } - - //returns path acronym for default location - protected String getSystemPathStubAcronym() { - return systemPathStub; - } - - protected String getFileName() { - return fileName; - } - - protected String getDescriptionKey() { - return descriptionKey; - } - - - - /** - * This remaining part of file declaration, when acronym is removed. - * See getDirViaAcronym. - * - * @return - */ - private String getStub() { - return clean(pathStub + File.separator + fileName); - } - - @Override - public String toString() { - return clean(getSystemPathStubAcronym() + File.separator + getStub()); - } - - /** - * For documentation purposes, the descriptor may be created as VARIABLE/custom/path. - * - * This is whole part, which is considered as setup-able. - * @return - */ - public String getDirViaAcronym() { - return clean(getSystemPathStubAcronym() + File.separator + pathStub); - } - - /** - * Remove garbage from paths. - * - * Currently this methods unify all multiple occurrences of separators - * to single one. Eg /path/to//file will become /path/to/file. - * - * Those artifacts maybe spread during various s=path+deparator+subdir+separator - * file=s+separator+filename - * - * @param s string to be cleaned - * @return cleaned string - */ - protected String clean(String s) { - while (s.contains(File.separator + File.separator)) { - s = s.replace(File.separator + File.separator, File.separator); - - } - return s; - } - - /** - * @return the translated description - */ - public String getDescription() { - return Translator.R(descriptionKey); - } - } private static class HomeFileDescriptor extends InfrastructureFileDescriptor {
--- a/netx/net/sourceforge/jnlp/controlpanel/AdvancedProxySettingsDialog.java Thu Apr 09 11:31:31 2015 -0400 +++ b/netx/net/sourceforge/jnlp/controlpanel/AdvancedProxySettingsDialog.java Fri Apr 10 12:47:01 2015 +0200 @@ -44,7 +44,7 @@ private boolean initialized = false; private static final String dialogTitle = Translator.R("APSDialogTitle"); - private DeploymentConfiguration config; // Configuration file which contains all the settings. + private final DeploymentConfiguration config; // Configuration file which contains all the settings. AdvancedProxySettingsPane topPanel;
--- a/netx/net/sourceforge/jnlp/controlpanel/AdvancedProxySettingsPane.java Thu Apr 09 11:31:31 2015 -0400 +++ b/netx/net/sourceforge/jnlp/controlpanel/AdvancedProxySettingsPane.java Fri Apr 10 12:47:01 2015 +0200 @@ -53,7 +53,7 @@ public class AdvancedProxySettingsPane extends JPanel { private JDialog parent; - private DeploymentConfiguration config; + private final DeploymentConfiguration config; /** List of properties used by this panel */ public static String[] properties = { "deployment.proxy.http.host",
--- a/netx/net/sourceforge/jnlp/controlpanel/CacheViewer.java Thu Apr 09 11:31:31 2015 -0400 +++ b/netx/net/sourceforge/jnlp/controlpanel/CacheViewer.java Fri Apr 10 12:47:01 2015 +0200 @@ -46,20 +46,14 @@ private boolean initialized = false; private static final String dialogTitle = Translator.R("CVCPDialogTitle"); - private DeploymentConfiguration config; // Configuration file which contains all the settings. CachePane topPanel; /** * Creates a new instance of the cache viewer. * - * @param config Deployment configuration file. */ - public CacheViewer(DeploymentConfiguration config) { + public CacheViewer() { super((Frame) null, dialogTitle, true); // Don't need a parent. - this.config = config; - if (config == null) { - throw new IllegalArgumentException("config: " + config); - } setIconImages(ImageResources.INSTANCE.getApplicationImages()); /* Prepare for adding components to dialog box */ @@ -125,11 +119,9 @@ /** * Display the cache viewer. - * - * @param config Configuration file. */ - public static void showCacheDialog(final DeploymentConfiguration config) { - CacheViewer psd = new CacheViewer(config); + public static void showCacheDialog() { + CacheViewer psd = new CacheViewer(); psd.setResizable(true); psd.centerDialog(); psd.setVisible(true);
--- a/netx/net/sourceforge/jnlp/controlpanel/DesktopShortcutPanel.java Thu Apr 09 11:31:31 2015 -0400 +++ b/netx/net/sourceforge/jnlp/controlpanel/DesktopShortcutPanel.java Fri Apr 10 12:47:01 2015 +0200 @@ -42,7 +42,7 @@ */ public class DesktopShortcutPanel extends NamedBorderPanel implements ItemListener { - private DeploymentConfiguration config; + private final DeploymentConfiguration config; /** * Create a new instance of the desktop shortcut settings panel.
--- a/netx/net/sourceforge/jnlp/controlpanel/JVMPanel.java Thu Apr 09 11:31:31 2015 -0400 +++ b/netx/net/sourceforge/jnlp/controlpanel/JVMPanel.java Fri Apr 10 12:47:01 2015 +0200 @@ -75,7 +75,7 @@ this.formattedText = formattedText; } } - private DeploymentConfiguration config; + private final DeploymentConfiguration config; private File lastPath = new File("/usr/lib/jvm/java/jre/"); JTextField testFieldArgumentsExec;
--- a/netx/net/sourceforge/jnlp/controlpanel/SecuritySettingsPanel.java Thu Apr 09 11:31:31 2015 -0400 +++ b/netx/net/sourceforge/jnlp/controlpanel/SecuritySettingsPanel.java Fri Apr 10 12:47:01 2015 +0200 @@ -43,7 +43,7 @@ @SuppressWarnings("serial") public class SecuritySettingsPanel extends NamedBorderPanel implements ActionListener { - private DeploymentConfiguration config; + private final DeploymentConfiguration config; // NOTE: All the ones listed with "Default" are in Oracle's implementation. // Not shown on deployments.properties webpage. Add support for these later!
--- a/netx/net/sourceforge/jnlp/controlpanel/TemporaryInternetFilesPanel.java Thu Apr 09 11:31:31 2015 -0400 +++ b/netx/net/sourceforge/jnlp/controlpanel/TemporaryInternetFilesPanel.java Fri Apr 10 12:47:01 2015 +0200 @@ -226,7 +226,7 @@ bViewFiles.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - CacheViewer.showCacheDialog(config); + CacheViewer.showCacheDialog(); } });
--- a/netx/net/sourceforge/jnlp/runtime/JNLPProxySelector.java Thu Apr 09 11:31:31 2015 -0400 +++ b/netx/net/sourceforge/jnlp/runtime/JNLPProxySelector.java Fri Apr 10 12:47:01 2015 +0200 @@ -106,7 +106,7 @@ pacEvaluator = PacEvaluatorFactory.getPacEvaluator(autoConfigUrl); } - bypassList = new ArrayList<String>(); + bypassList = new ArrayList<>(); String proxyBypass = config.getProperty(DeploymentConfiguration.KEY_PROXY_BYPASS_LIST); if (proxyBypass != null) { StringTokenizer tokenizer = new StringTokenizer(proxyBypass, ",");
--- a/netx/net/sourceforge/jnlp/security/KeyStores.java Thu Apr 09 11:31:31 2015 -0400 +++ b/netx/net/sourceforge/jnlp/security/KeyStores.java Fri Apr 10 12:47:01 2015 +0200 @@ -52,6 +52,8 @@ import java.util.Map; import java.util.StringTokenizer; +import net.sourceforge.jnlp.config.InfrastructureFileDescriptor; + import net.sourceforge.jnlp.config.PathsAndFiles; import net.sourceforge.jnlp.runtime.Translator; import net.sourceforge.jnlp.util.FileUtils; @@ -240,7 +242,7 @@ * @param type the specified type of the key store to be returned. * @return the location of the key store. */ - public static final PathsAndFiles.InfrastructureFileDescriptor getKeyStoreLocation(Level level, Type type) { + public static final InfrastructureFileDescriptor getKeyStoreLocation(Level level, Type type) { switch (level) { case SYSTEM: switch (type) {
--- a/netx/net/sourceforge/jnlp/util/docprovider/ItwebSettingsTextsProvider.java Thu Apr 09 11:31:31 2015 -0400 +++ b/netx/net/sourceforge/jnlp/util/docprovider/ItwebSettingsTextsProvider.java Fri Apr 10 12:47:01 2015 +0200 @@ -46,6 +46,7 @@ import net.sourceforge.jnlp.config.Defaults; import net.sourceforge.jnlp.OptionsDefinitions; import net.sourceforge.jnlp.config.DeploymentConfiguration; +import net.sourceforge.jnlp.config.InfrastructureFileDescriptor; import net.sourceforge.jnlp.config.PathsAndFiles; import net.sourceforge.jnlp.config.Setting; import net.sourceforge.jnlp.config.ValueValidator; @@ -135,11 +136,11 @@ return o1.getKey().compareTo(o2.getKey()); } }); - List<PathsAndFiles.InfrastructureFileDescriptor> files = PathsAndFiles.getAllFiles(); + List<InfrastructureFileDescriptor> files = PathsAndFiles.getAllFiles(); for (Map.Entry<String, Setting<String>> entry : defaults) { String defaultValue = entry.getValue().getDefaultValue(); String fileAcronom = null; - for (PathsAndFiles.InfrastructureFileDescriptor f : files) { + for (InfrastructureFileDescriptor f : files) { if (matchSttingsValueWithInfrastrucutreFile(entry.getValue(), f)) { fileAcronom = f.toString(); break;
--- a/netx/net/sourceforge/jnlp/util/docprovider/TextsProvider.java Thu Apr 09 11:31:31 2015 -0400 +++ b/netx/net/sourceforge/jnlp/util/docprovider/TextsProvider.java Fri Apr 10 12:47:01 2015 +0200 @@ -52,7 +52,7 @@ import java.util.Set; import net.sourceforge.jnlp.config.Defaults; import net.sourceforge.jnlp.OptionsDefinitions; -import net.sourceforge.jnlp.config.PathsAndFiles; +import net.sourceforge.jnlp.config.InfrastructureFileDescriptor; import net.sourceforge.jnlp.config.Setting; import net.sourceforge.jnlp.runtime.Translator; import net.sourceforge.jnlp.util.docprovider.formatters.formatters.Formatter; @@ -161,17 +161,17 @@ } } - protected String getFiles(List<PathsAndFiles.InfrastructureFileDescriptor> files) { + protected String getFiles(List<InfrastructureFileDescriptor> files) { StringBuilder sb = new StringBuilder(); Set<Map.Entry<String, Setting<String>>> defs = Defaults.getDefaults().entrySet(); - Collections.sort(files, new Comparator<PathsAndFiles.InfrastructureFileDescriptor>() { + Collections.sort(files, new Comparator<InfrastructureFileDescriptor>() { @Override - public int compare(PathsAndFiles.InfrastructureFileDescriptor o1, PathsAndFiles.InfrastructureFileDescriptor o2) { + public int compare(InfrastructureFileDescriptor o1, InfrastructureFileDescriptor o2) { return o1.toString().compareTo(o2.toString()); } }); - for (PathsAndFiles.InfrastructureFileDescriptor f : files) { + for (InfrastructureFileDescriptor f : files) { String path = expandVariables ? f.getFullPath() : f.toString(); String modified = ""; String fGetFullPath=removeFileProtocol(f.getFullPath()); @@ -192,7 +192,7 @@ return formatter.wrapParagraph(sb.toString()); } - protected boolean matchSttingsValueWithInfrastrucutreFile(Setting<String> entry, PathsAndFiles.InfrastructureFileDescriptor f) { + protected boolean matchSttingsValueWithInfrastrucutreFile(Setting<String> entry, InfrastructureFileDescriptor f) { if (entry == null || entry.getDefaultValue() == null) { return false; }
--- a/plugin/icedteanp/java/sun/applet/PluginProxySelector.java Thu Apr 09 11:31:31 2015 -0400 +++ b/plugin/icedteanp/java/sun/applet/PluginProxySelector.java Fri Apr 10 12:47:01 2015 +0200 @@ -63,7 +63,7 @@ public class PluginProxySelector extends JNLPProxySelector { - private TimedHashMap<String, Proxy> proxyCache = new TimedHashMap<String, Proxy>(); + private TimedHashMap<String, Proxy> proxyCache = new TimedHashMap<>(); public PluginProxySelector(DeploymentConfiguration config) { super(config);
--- a/tests/netx/unit/net/sourceforge/jnlp/cache/CacheLRUWrapperTest.java Thu Apr 09 11:31:31 2015 -0400 +++ b/tests/netx/unit/net/sourceforge/jnlp/cache/CacheLRUWrapperTest.java Fri Apr 10 12:47:01 2015 +0200 @@ -50,6 +50,7 @@ import org.junit.Test; import net.sourceforge.jnlp.ServerAccess; +import net.sourceforge.jnlp.config.InfrastructureFileDescriptor; import net.sourceforge.jnlp.config.PathsAndFiles; import net.sourceforge.jnlp.util.CacheTestUtils; @@ -59,6 +60,7 @@ private static final String cacheIndexFileName = PathsAndFiles.CACHE_INDEX_FILE_NAME + "_testing"; private static final File javaTmp = new File(System.getProperty("java.io.tmpdir")); private static final File tmpCache; + private static final File tmpIndexFile; static { try { @@ -69,13 +71,37 @@ if (!tmpCache.isDirectory()) { throw new IOException("Unsuccess to create tmpfile, remove it and createsame directory"); } - + tmpIndexFile = new File(tmpCache, cacheIndexFileName); } catch (IOException ex) { throw new RuntimeException(ex); } } - private static final CacheLRUWrapper clw = new CacheLRUWrapper(new File(tmpCache, cacheIndexFileName), tmpCache); + + private static class DummyInfrastructureFileDescriptor extends InfrastructureFileDescriptor{ + private final File backend; + + + private DummyInfrastructureFileDescriptor(File backend) { + super(); + this.backend=backend; + } + + @Override + public File getFile() { + return backend; + } + + @Override + public String getFullPath() { + return backend.getAbsolutePath(); + } + + } + + private static final CacheLRUWrapper clw = new CacheLRUWrapper( + new DummyInfrastructureFileDescriptor(tmpIndexFile), + new DummyInfrastructureFileDescriptor(tmpCache)); private final int noEntriesCacheFile = 1000; @@ -93,7 +119,7 @@ @Test public void testLoadStoreTiming() throws InterruptedException { - final File cacheIndexFile = clw.getRecentlyUsedFile(); + final File cacheIndexFile = clw.getRecentlyUsedFile().getFile(); cacheIndexFile.delete(); try { int noLoops = 1000; @@ -134,7 +160,7 @@ // fill cache index file for(int i = 0; i < noEntries; i++) { - String path = clw.getRecentlyUsedFile().getAbsolutePath() + File.separatorChar + i + File.separatorChar + "test" + i + ".jar"; + String path = clw.getRecentlyUsedFile().getFullPath() + File.separatorChar + i + File.separatorChar + "test" + i + ".jar"; String key = clw.generateKey(path); clw.addEntry(key, path); } @@ -143,7 +169,7 @@ @Test public void testModTimestampAfterStore() throws InterruptedException { - final File cacheIndexFile = clw.getRecentlyUsedFile(); + final File cacheIndexFile = clw.getRecentlyUsedFile().getFile(); cacheIndexFile.delete(); try{ clw.lock();
--- a/tests/netx/unit/net/sourceforge/jnlp/controlpanel/CommandLineTest.java Thu Apr 09 11:31:31 2015 -0400 +++ b/tests/netx/unit/net/sourceforge/jnlp/controlpanel/CommandLineTest.java Fri Apr 10 12:47:01 2015 +0200 @@ -30,6 +30,7 @@ import net.sourceforge.jnlp.OptionsDefinitions; import net.sourceforge.jnlp.config.PathsAndFiles; +import net.sourceforge.jnlp.util.logging.NoStdOutErrTest; import net.sourceforge.jnlp.util.logging.OutputController; import net.sourceforge.jnlp.util.optionparser.OptionParser; import net.sourceforge.jnlp.util.optionparser.UnevenParameterException; @@ -37,7 +38,7 @@ import org.junit.BeforeClass; import org.junit.Test; -public class CommandLineTest { +public class CommandLineTest extends NoStdOutErrTest{ public static final int ERROR = 1; public static final int SUCCESS = 0; @@ -91,7 +92,7 @@ ByteArrayOutputStream outStream = getOutputControllerStream(); String[] args = { - "set", "unknown", "ALLOW_UNSIGNED" + "set", "unknown", "does_not_matter" }; OptionParser optionParser = new OptionParser(args, OptionsDefinitions.getItwsettingsCommands()); CommandLine commandLine = new CommandLine(optionParser); @@ -150,7 +151,7 @@ @Test public void testSetPropertyWithIncorrectValue() throws IOException { String[] args = { - "set", "deployment.security.level", "ALLOW_ONLY_SAFE_APPLETS" + "set", "deployment.security.level", "INTENTIONALLY_INCORRECT" }; OptionParser optionParser = new OptionParser(args, OptionsDefinitions.getItwsettingsCommands());
--- a/tests/netx/unit/net/sourceforge/jnlp/security/KeyStoresTest.java Thu Apr 09 11:31:31 2015 -0400 +++ b/tests/netx/unit/net/sourceforge/jnlp/security/KeyStoresTest.java Fri Apr 10 12:47:01 2015 +0200 @@ -37,6 +37,7 @@ package net.sourceforge.jnlp.security; import java.security.Permission; +import net.sourceforge.jnlp.config.InfrastructureFileDescriptor; import net.sourceforge.jnlp.config.PathsAndFiles; import org.junit.AfterClass; import org.junit.Assert; @@ -59,10 +60,9 @@ System.setSecurityManager(null); } - //TODO once setConfig is removed, ensure SM is enforced also from PathsAndFiles @Test public void getKeyStoreUserLocationTest() { - PathsAndFiles.InfrastructureFileDescriptor s; + InfrastructureFileDescriptor s; System.setSecurityManager(null); s = KeyStores.getKeyStoreLocation(KeyStores.Level.USER, KeyStores.Type.CA_CERTS); Assert.assertEquals(s.getFile(), PathsAndFiles.USER_CACERTS.getFile()); @@ -78,7 +78,7 @@ @Test public void getKeyStoreSystemLocationTest() { - PathsAndFiles.InfrastructureFileDescriptor s; + InfrastructureFileDescriptor s; System.setSecurityManager(null); s = KeyStores.getKeyStoreLocation(KeyStores.Level.SYSTEM, KeyStores.Type.CA_CERTS); Assert.assertEquals(s.getFile(), PathsAndFiles.SYS_CACERT.getFile()); @@ -96,7 +96,7 @@ public void getKeyStoreUserLocationTestSM() { DummySM dm = new DummySM(); System.setSecurityManager(dm); - PathsAndFiles.InfrastructureFileDescriptor s; + InfrastructureFileDescriptor s; s = KeyStores.getKeyStoreLocation(KeyStores.Level.USER, KeyStores.Type.CA_CERTS); Assert.assertEquals(s.getFile(), PathsAndFiles.USER_CACERTS.getFile()); s = KeyStores.getKeyStoreLocation(KeyStores.Level.USER, KeyStores.Type.CERTS); @@ -114,7 +114,7 @@ public void getKeyStoreSystemLocationTestSM() { DummySM dm = new DummySM(); System.setSecurityManager(dm); - PathsAndFiles.InfrastructureFileDescriptor s; + InfrastructureFileDescriptor s; s = KeyStores.getKeyStoreLocation(KeyStores.Level.SYSTEM, KeyStores.Type.CA_CERTS); Assert.assertEquals(s.getFile(), PathsAndFiles.SYS_CACERT.getFile()); s = KeyStores.getKeyStoreLocation(KeyStores.Level.SYSTEM, KeyStores.Type.CERTS);
--- a/tests/test-extensions/net/sourceforge/jnlp/tools/DeploymentPropetiesModifier.java Thu Apr 09 11:31:31 2015 -0400 +++ b/tests/test-extensions/net/sourceforge/jnlp/tools/DeploymentPropetiesModifier.java Fri Apr 10 12:47:01 2015 +0200 @@ -38,13 +38,14 @@ package net.sourceforge.jnlp.tools; import java.io.IOException; +import net.sourceforge.jnlp.config.InfrastructureFileDescriptor; import net.sourceforge.jnlp.config.PathsAndFiles; import net.sourceforge.jnlp.util.FileUtils; public class DeploymentPropetiesModifier { - private final PathsAndFiles.InfrastructureFileDescriptor src; + private final InfrastructureFileDescriptor src; private String savedValue; private String requestedProperty; private String requestedValue; @@ -54,7 +55,7 @@ this(PathsAndFiles.USER_DEPLOYMENT_FILE); } - public DeploymentPropetiesModifier(PathsAndFiles.InfrastructureFileDescriptor src) { + public DeploymentPropetiesModifier(InfrastructureFileDescriptor src) { this.src = src; isPropertiesSet = false; }