From f5661da5958510ae0f4b8413df097103aacaa76c Mon Sep 17 00:00:00 2001 From: zzz <zzz@mail.i2p> Date: Sun, 27 Apr 2014 14:53:15 +0000 Subject: [PATCH] * Router: Set killVMOnEnd before runRouter() (for azi2phelper) * RoutingKeyGenerator: Don't assume UTC (for azi2phelper) --- .../src/net/i2p/data/RoutingKeyGenerator.java | 7 ++++- router/java/src/net/i2p/router/Router.java | 26 ++++++++++++++++--- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/core/java/src/net/i2p/data/RoutingKeyGenerator.java b/core/java/src/net/i2p/data/RoutingKeyGenerator.java index e66049cc78..497262dbd2 100644 --- a/core/java/src/net/i2p/data/RoutingKeyGenerator.java +++ b/core/java/src/net/i2p/data/RoutingKeyGenerator.java @@ -13,6 +13,7 @@ import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; +import java.util.Locale; import java.util.TimeZone; import net.i2p.I2PAppContext; @@ -64,7 +65,11 @@ public class RoutingKeyGenerator { private final static Calendar _cal = GregorianCalendar.getInstance(TimeZone.getTimeZone("GMT")); private static final String FORMAT = "yyyyMMdd"; private static final int LENGTH = FORMAT.length(); - private final static SimpleDateFormat _fmt = new SimpleDateFormat(FORMAT); + private final static SimpleDateFormat _fmt = new SimpleDateFormat(FORMAT, Locale.US); + static { + // make sure GMT is set, azi2phelper Vuze plugin is disabling static JVM TZ setting in Router.java + _fmt.setCalendar(_cal); + } /** * The current (today's) mod data. diff --git a/router/java/src/net/i2p/router/Router.java b/router/java/src/net/i2p/router/Router.java index 4498e27982..f6eb8a907e 100644 --- a/router/java/src/net/i2p/router/Router.java +++ b/router/java/src/net/i2p/router/Router.java @@ -138,11 +138,27 @@ public class Router implements RouterClock.ClockShiftListener { */ public Router() { this(null, null); } + /** + * Instantiation only. Starts no threads. Does not install updates. + * RouterContext is created but not initialized. + * You must call runRouter() after any constructor to start things up. + */ public Router(Properties envProps) { this(null, envProps); } + /** + * Instantiation only. Starts no threads. Does not install updates. + * RouterContext is created but not initialized. + * You must call runRouter() after any constructor to start things up. + */ public Router(String configFilename) { this(configFilename, null); } + /** + * Instantiation only. Starts no threads. Does not install updates. + * RouterContext is created but not initialized. + * You must call runRouter() after any constructor to start things up. + */ public Router(String configFilename, Properties envProps) { + _killVMOnEnd = true; _gracefulExitCode = -1; _config = new ConcurrentHashMap<String, String>(); @@ -307,7 +323,6 @@ public class Router implements RouterClock.ClockShiftListener { _log = _context.logManager().getLog(Router.class); _log.info("New router created with config file " + _configFilename); //_sessionKeyPersistenceHelper = new SessionKeyPersistenceHelper(_context); - _killVMOnEnd = true; _oomListener = new OOMListener(_context); _shutdownHook = new ShutdownHook(_context); @@ -333,7 +348,7 @@ public class Router implements RouterClock.ClockShiftListener { /** * Configure the router to kill the JVM when the router shuts down, as well * as whether to explicitly halt the JVM during the hard fail process. - * + * Defaults to true. Set to false for embedded before calling runRouter() */ public void setKillVMOnEnd(boolean shouldDie) { _killVMOnEnd = shouldDie; } @@ -429,7 +444,10 @@ public class Router implements RouterClock.ClockShiftListener { /** * This must be called after instantiation. * Starts the threads. Does not install updates. - * Most users will just call main() instead. + * This is for embedded use. + * Standard standalone installation uses main() instead, which + * checks for updates and then calls this. + * * @since public as of 0.9 for Android and other embedded uses */ public synchronized void runRouter() { @@ -1108,6 +1126,8 @@ public class Router implements RouterClock.ClockShiftListener { /** * Usage: Router [rebuild] * No other options allowed, for now + * Instantiates Router(), and either installs updates and exits, + * or calls runRouter(). * * @param args null ok * @throws IllegalArgumentException -- GitLab