diff --git a/core/java/src/net/i2p/data/KeysAndCert.java b/core/java/src/net/i2p/data/KeysAndCert.java index 3a181c7a95..8e9bcaab1c 100644 --- a/core/java/src/net/i2p/data/KeysAndCert.java +++ b/core/java/src/net/i2p/data/KeysAndCert.java @@ -151,11 +151,23 @@ public class KeysAndCert extends DataStructureImpl { return buf.toString(); } + /** + * Throws IllegalStateException if keys and cert are not initialized, + * as of 0.9.12. Prior to that, returned null. + * + * @throws IllegalStateException + */ @Override public Hash calculateHash() { return getHash(); } + /** + * Throws IllegalStateException if keys and cert are not initialized, + * as of 0.9.12. Prior to that, returned null. + * + * @throws IllegalStateException + */ public Hash getHash() { if (__calculatedHash != null) return __calculatedHash; diff --git a/core/java/test/junit/net/i2p/data/RouterIdentityTest.java b/core/java/test/junit/net/i2p/data/RouterIdentityTest.java index ce1978ebcd..e5fdc93e9e 100644 --- a/core/java/test/junit/net/i2p/data/RouterIdentityTest.java +++ b/core/java/test/junit/net/i2p/data/RouterIdentityTest.java @@ -101,9 +101,15 @@ public class RouterIdentityTest extends StructureTest { ident.calculateHash(); } - public void testBadHash() throws Exception{ + public void testBadHash() throws Exception { RouterIdentity ident = new RouterIdentity(); - ident.getHash(); + boolean error = false; + try { + ident.getHash(); + } catch (IllegalStateException ise) { + error = true; + } + assertTrue(error); }