From c82dbd82b16b5c12ac0aec5f2849ece09ead2941 Mon Sep 17 00:00:00 2001 From: zzz <zzz@mail.i2p> Date: Sat, 31 Dec 2011 14:49:47 +0000 Subject: [PATCH] * Fix log NPE when saveConfig() fails at startup, thx kytv (backport from jetty6 branch) --- history.txt | 7 +++++++ router/java/src/net/i2p/router/Router.java | 16 ++++++++++++++-- .../java/src/net/i2p/router/RouterVersion.java | 2 +- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/history.txt b/history.txt index b18f9bb9df..4901d88a97 100644 --- a/history.txt +++ b/history.txt @@ -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 * Spanish and Swedish translation updates from Transifex diff --git a/router/java/src/net/i2p/router/Router.java b/router/java/src/net/i2p/router/Router.java index 5299dc1781..08ea93bd8c 100644 --- a/router/java/src/net/i2p/router/Router.java +++ b/router/java/src/net/i2p/router/Router.java @@ -426,7 +426,11 @@ public class Router implements RouterClock.ClockShiftListener { 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) { Log log = null; if (ctx != null) { @@ -444,10 +448,15 @@ public class Router implements RouterClock.ClockShiftListener { } else { if (log != null) 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) { if (log != null) log.error("Error loading the router configuration from " + filename, ioe); + else + System.err.println("Error loading the router configuration from " + filename + ": " + ioe); } return props; } @@ -1193,8 +1202,11 @@ public class Router implements RouterClock.ClockShiftListener { } fos.write(buf.toString().getBytes("UTF-8")); } 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); + else + System.err.println("Error saving the config to " + _configFilename + ": " + ioe); return false; } finally { if (fos != null) try { fos.close(); } catch (IOException ioe) {} diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index 3c775e75ad..0e04b1445c 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -18,7 +18,7 @@ public class RouterVersion { /** deprecated */ public final static String ID = "Monotone"; public final static String VERSION = CoreVersion.VERSION; - public final static long BUILD = 25; + public final static long BUILD = 26; /** for example "-test" */ public final static String EXTRA = "-rc"; -- GitLab