diff --git a/core/java/src/net/i2p/I2PAppContext.java b/core/java/src/net/i2p/I2PAppContext.java index 46cfc3742c5f897946ab99bd00a13fcc1c9b11b0..136079fd025b232b972ba96175d7abf072c4b148 100644 --- a/core/java/src/net/i2p/I2PAppContext.java +++ b/core/java/src/net/i2p/I2PAppContext.java @@ -121,6 +121,7 @@ public class I2PAppContext { private final File _logDir; private final File _appDir; private volatile File _tmpDir; + private final Random _tmpDirRand = new Random(); // split up big lock on this to avoid deadlocks private final Object _lock1 = new Object(), _lock2 = new Object(), _lock3 = new Object(), _lock4 = new Object(), _lock5 = new Object(), _lock6 = new Object(), _lock7 = new Object(), _lock8 = new Object(), @@ -403,7 +404,7 @@ public class I2PAppContext { String d = getProperty("i2p.dir.temp", System.getProperty("java.io.tmpdir")); // our random() probably isn't warmed up yet byte[] rand = new byte[6]; - (new Random()).nextBytes(rand); + _tmpDirRand.nextBytes(rand); String f = "i2p-" + Base64.encode(rand) + ".tmp"; _tmpDir = new SecureDirectory(d, f); if (_tmpDir.exists()) { diff --git a/core/java/src/net/i2p/util/Clock.java b/core/java/src/net/i2p/util/Clock.java index 3efbbb7d69f1c45e72be6f3da2f4ae80b4d82a9c..a087d3288a51a356137b3bceba2ea9c488336ee7 100644 --- a/core/java/src/net/i2p/util/Clock.java +++ b/core/java/src/net/i2p/util/Clock.java @@ -113,7 +113,7 @@ public class Clock implements Timestamper.UpdateListener { /* * @return the current delta from System.currentTimeMillis() in milliseconds */ - public long getOffset() { + public synchronized long getOffset() { return _offset; }