From 3ceb83d40e131174a987656a18ea5782196b55ab Mon Sep 17 00:00:00 2001 From: zzz <zzz@mail.i2p> Date: Sun, 7 Oct 2012 20:48:25 +0000 Subject: [PATCH] * I2PAppContext: Improved synching in constructor --- core/java/src/net/i2p/I2PAppContext.java | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/core/java/src/net/i2p/I2PAppContext.java b/core/java/src/net/i2p/I2PAppContext.java index 69e443cfa9..bd1085f180 100644 --- a/core/java/src/net/i2p/I2PAppContext.java +++ b/core/java/src/net/i2p/I2PAppContext.java @@ -64,7 +64,7 @@ import net.i2p.util.I2PProperties.I2PPropertyCallback; * contexts should build their own context as soon as possible (within the main(..)) * so that any referenced components will latch on to that context instead of * instantiating a new one. However, there are situations in which both can be - * relevent. + * relevant. * */ public class I2PAppContext { @@ -196,16 +196,7 @@ public class I2PAppContext { * Will only apply if there is no global context now. */ private I2PAppContext(boolean doInit, Properties envProps) { - if (doInit) { - synchronized (I2PAppContext.class) { - if (_globalAppContext == null) { - _globalAppContext = this; - } else { - System.out.println("Warning - New context not replacing old one, you now have a second one"); - (new Exception("I did it")).printStackTrace(); - } - } - } + synchronized (I2PAppContext.class) { _overrideProps = new I2PProperties(); if (envProps != null) _overrideProps.putAll(envProps); @@ -319,6 +310,16 @@ public class I2PAppContext { System.err.println("PID directory: " + _pidDir.getAbsolutePath()); System.err.println("Temp directory: " + getTempDir().getAbsolutePath()); ******/ + + if (doInit) { + if (_globalAppContext == null) { + _globalAppContext = this; + } else { + System.out.println("Warning - New context not replacing old one, you now have a second one"); + (new Exception("I did it")).printStackTrace(); + } + } + } // synch } /** -- GitLab