git://source.jalview.org
/
jalview.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
eb1d351
)
JAL-1270 JAL-2885 clear properties before load
author
gmungoc
<g.m.carstairs@dundee.ac.uk>
Tue, 16 Jan 2018 12:19:24 +0000
(12:19 +0000)
committer
gmungoc
<g.m.carstairs@dundee.ac.uk>
Tue, 16 Jan 2018 12:19:24 +0000
(12:19 +0000)
src/jalview/bin/Cache.java
patch
|
blob
|
history
diff --git
a/src/jalview/bin/Cache.java
b/src/jalview/bin/Cache.java
index
dc50843
..
dcd6546
100755
(executable)
--- a/
src/jalview/bin/Cache.java
+++ b/
src/jalview/bin/Cache.java
@@
-281,7
+281,7
@@
public class Cache
@Override
public synchronized Enumeration<Object> keys()
{
@Override
public synchronized Enumeration<Object> keys()
{
- return Collections.enumeration(new TreeSet<Object>(super.keySet()));
+ return Collections.enumeration(new TreeSet<>(super.keySet()));
}
};
}
};
@@
-334,7
+334,10
@@
public class Cache
}
}
}
}
- /** Called when Jalview is started */
+ /**
+ * Loads properties from the given properties file. Any existing properties
+ * are first cleared.
+ */
public static void loadProperties(String propsFile)
{
propertiesFile = propsFile;
public static void loadProperties(String propsFile)
{
propertiesFile = propsFile;
@@
-369,6
+372,7
@@
public class Cache
{
fis = new FileInputStream(propertiesFile);
}
{
fis = new FileInputStream(propertiesFile);
}
+ applicationProperties.clear();
applicationProperties.load(fis);
// remove any old build properties
applicationProperties.load(fis);
// remove any old build properties
@@
-621,14
+625,14
@@
public class Cache
* @param obj
* String value of property
*
* @param obj
* String value of property
*
- * @return String value of property
+ * @return previous value of property (or null)
*/
*/
- public static String setProperty(String key, String obj)
+ public static Object setProperty(String key, String obj)
{
{
-
+ Object oldValue = null;
try
{
try
{
- applicationProperties.setProperty(key, obj);
+ oldValue = applicationProperties.setProperty(key, obj);
if (!propsAreReadOnly)
{
FileOutputStream out = new FileOutputStream(propertiesFile);
if (!propsAreReadOnly)
{
FileOutputStream out = new FileOutputStream(propertiesFile);
@@
-640,7
+644,7
@@
public class Cache
System.out.println(
"Error setting property: " + key + " " + obj + "\n" + ex);
}
System.out.println(
"Error setting property: " + key + " " + obj + "\n" + ex);
}
- return obj;
+ return oldValue;
}
/**
}
/**