From b0bca2f16cfbe932b2c146164820d771b925914f Mon Sep 17 00:00:00 2001 From: zzz <zzz@mail.i2p> Date: Wed, 12 Jun 2019 18:14:18 +0000 Subject: [PATCH] Util: Avoid dup context warning when SU3File called twice from gradle --- core/java/src/net/i2p/crypto/SU3File.java | 28 +++++++++++++++-------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/core/java/src/net/i2p/crypto/SU3File.java b/core/java/src/net/i2p/crypto/SU3File.java index f22918273e..21f0cd7bc4 100644 --- a/core/java/src/net/i2p/crypto/SU3File.java +++ b/core/java/src/net/i2p/crypto/SU3File.java @@ -623,22 +623,30 @@ public class SU3File { } else if ("showversion".equals(cmd)) { ok = showVersionCLI(a.get(0)); } else if ("sign".equals(cmd)) { - // speed things up by specifying a small PRNG buffer size - Properties props = new Properties(); - props.setProperty("prng.bufferSize", "16384"); - new I2PAppContext(props); + if (I2PAppContext.getCurrentContext() == null) { + // speed things up by specifying a small PRNG buffer size + Properties props = new Properties(); + props.setProperty("prng.bufferSize", "16384"); + new I2PAppContext(props); + } ok = signCLI(stype, ctype, ftype, a.get(0), a.get(1), a.get(2), a.get(3), a.get(4), "", kspass); } else if ("bulksign".equals(cmd)) { - Properties props = new Properties(); - props.setProperty("prng.bufferSize", "16384"); - new I2PAppContext(props); + if (I2PAppContext.getCurrentContext() == null) { + // speed things up by specifying a small PRNG buffer size + Properties props = new Properties(); + props.setProperty("prng.bufferSize", "16384"); + new I2PAppContext(props); + } ok = bulkSignCLI(stype, ctype, a.get(0), a.get(1), a.get(2), a.get(3), kspass); } else if ("verifysig".equals(cmd)) { ok = verifySigCLI(a.get(0), kfile); } else if ("keygen".equals(cmd)) { - Properties props = new Properties(); - props.setProperty("prng.bufferSize", "16384"); - new I2PAppContext(props); + if (I2PAppContext.getCurrentContext() == null) { + // speed things up by specifying a small PRNG buffer size + Properties props = new Properties(); + props.setProperty("prng.bufferSize", "16384"); + new I2PAppContext(props); + } ok = genKeysCLI(stype, a.get(0), a.get(1), crlfile, a.get(2), kspass); } else if ("extract".equals(cmd)) { String outfile = (a.size() > 1) ? a.get(1) : null; -- GitLab