From 9b757605686ce9ddddb07411ea12289274119c9d Mon Sep 17 00:00:00 2001 From: hns Date: Wed, 3 Oct 2007 14:40:21 +0000 Subject: [PATCH] * Add try/catch and logging to updateProperties(), and remove duplicate code. --- src/helma/util/CacheMap.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/helma/util/CacheMap.java b/src/helma/util/CacheMap.java index a701b5e4..fba8e516 100644 --- a/src/helma/util/CacheMap.java +++ b/src/helma/util/CacheMap.java @@ -286,14 +286,24 @@ public class CacheMap implements ObjectCache { /// Set the application to use for debug and profiling output public void init(Application app) { this.app = app; - int cacheSize = Integer.parseInt(app.getProperty("cachesize", "1000")); - setCapacity(cacheSize); + if (app != null) { + updateProperties(app.getProperties()); + } } /// The app properties have been modified, reload settings public void updateProperties(Properties props) { - int cacheSize = Integer.parseInt(props.getProperty("cachesize", "1000")); - setCapacity(cacheSize); + try { + int cacheSize = Integer.parseInt(props.getProperty("cachesize", "1000")); + 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() {