* Add try/catch and logging to updateProperties(), and remove duplicate code.
This commit is contained in:
parent
72fffb0aa1
commit
9b75760568
1 changed files with 14 additions and 4 deletions
|
@ -286,14 +286,24 @@ public class CacheMap implements ObjectCache {
|
||||||
/// Set the application to use for debug and profiling output
|
/// Set the application to use for debug and profiling output
|
||||||
public void init(Application app) {
|
public void init(Application app) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
int cacheSize = Integer.parseInt(app.getProperty("cachesize", "1000"));
|
if (app != null) {
|
||||||
setCapacity(cacheSize);
|
updateProperties(app.getProperties());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The app properties have been modified, reload settings
|
/// The app properties have been modified, reload settings
|
||||||
public void updateProperties(Properties props) {
|
public void updateProperties(Properties props) {
|
||||||
|
try {
|
||||||
int cacheSize = Integer.parseInt(props.getProperty("cachesize", "1000"));
|
int cacheSize = Integer.parseInt(props.getProperty("cachesize", "1000"));
|
||||||
setCapacity(cacheSize);
|
setCapacity(cacheSize);
|
||||||
|
} catch (Exception x) {
|
||||||
|
String message = "Invalid cachesize setting: " + props.getProperty("cachesize");
|
||||||
|
if (app != null) {
|
||||||
|
app.logError(message);
|
||||||
|
} else {
|
||||||
|
System.err.println(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized Object[] getCachedObjects() {
|
public synchronized Object[] getCachedObjects() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue