* Fix log NPE when saveConfig() fails at startup, thx kytv (backport from jetty6 branch)

This commit is contained in:
zzz
2011-12-31 14:49:47 +00:00
parent 5346dc1a98
commit c82dbd82b1
3 changed files with 22 additions and 3 deletions

View File

@ -1,3 +1,10 @@
2011-12-31 zzz
* Fix log NPE when saveConfig() fails at startup, thx kytv
(backport from jetty6 branch)
2011-12-30 zzz
* New Estonian translation thanks ajutine
2011-12-27 kytv 2011-12-27 kytv
* Spanish and Swedish translation updates from Transifex * Spanish and Swedish translation updates from Transifex

View File

@ -426,7 +426,11 @@ public class Router implements RouterClock.ClockShiftListener {
foo.putAll(config); foo.putAll(config);
} }
/** this does not use ctx.getConfigDir(), must provide a full path in filename */ /**
* this does not use ctx.getConfigDir(), must provide a full path in filename
*
* @param ctx will be null at startup when called from constructor
*/
private static Properties getConfig(RouterContext ctx, String filename) { private static Properties getConfig(RouterContext ctx, String filename) {
Log log = null; Log log = null;
if (ctx != null) { if (ctx != null) {
@ -444,10 +448,15 @@ public class Router implements RouterClock.ClockShiftListener {
} else { } else {
if (log != null) if (log != null)
log.warn("Configuration file " + filename + " does not exist"); log.warn("Configuration file " + filename + " does not exist");
// normal not to exist at first install
//else
// System.err.println("WARNING: Configuration file " + filename + " does not exist");
} }
} catch (Exception ioe) { } catch (Exception ioe) {
if (log != null) if (log != null)
log.error("Error loading the router configuration from " + filename, ioe); log.error("Error loading the router configuration from " + filename, ioe);
else
System.err.println("Error loading the router configuration from " + filename + ": " + ioe);
} }
return props; return props;
} }
@ -1193,8 +1202,11 @@ public class Router implements RouterClock.ClockShiftListener {
} }
fos.write(buf.toString().getBytes("UTF-8")); fos.write(buf.toString().getBytes("UTF-8"));
} catch (IOException ioe) { } catch (IOException ioe) {
if (_log.shouldLog(Log.ERROR)) // warning, _log will be null when called from constructor
if (_log != null)
_log.error("Error saving the config to " + _configFilename, ioe); _log.error("Error saving the config to " + _configFilename, ioe);
else
System.err.println("Error saving the config to " + _configFilename + ": " + ioe);
return false; return false;
} finally { } finally {
if (fos != null) try { fos.close(); } catch (IOException ioe) {} if (fos != null) try { fos.close(); } catch (IOException ioe) {}

View File

@ -18,7 +18,7 @@ public class RouterVersion {
/** deprecated */ /** deprecated */
public final static String ID = "Monotone"; public final static String ID = "Monotone";
public final static String VERSION = CoreVersion.VERSION; public final static String VERSION = CoreVersion.VERSION;
public final static long BUILD = 25; public final static long BUILD = 26;
/** for example "-test" */ /** for example "-test" */
public final static String EXTRA = "-rc"; public final static String EXTRA = "-rc";