diff options
author | Neil Fuller <nfuller@google.com> | 2014-06-19 09:10:43 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2014-06-17 22:04:58 +0000 |
commit | 9aad55279f870ac0dec65f0fe87af6e2fe79bf1b (patch) | |
tree | 25d36c71ea6064f945728e55bdf2b8d1f9f8e3ee /luni | |
parent | f6bb79b2b7f6aa6a81db0756fe88acd7ff5fedd7 (diff) | |
parent | 142b0399f6ea20d46033fba94718bb22c3b4b7cc (diff) | |
download | libcore-9aad55279f870ac0dec65f0fe87af6e2fe79bf1b.zip libcore-9aad55279f870ac0dec65f0fe87af6e2fe79bf1b.tar.gz libcore-9aad55279f870ac0dec65f0fe87af6e2fe79bf1b.tar.bz2 |
Merge "CTS fix: Signature2Test.test_clone()"
Diffstat (limited to 'luni')
-rw-r--r-- | luni/src/main/java/java/security/Signature.java | 2 | ||||
-rw-r--r-- | luni/src/test/java/org/apache/harmony/security/tests/java/security/Signature2Test.java | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/luni/src/main/java/java/security/Signature.java b/luni/src/main/java/java/security/Signature.java index 7dd7d93..a39d59b 100644 --- a/luni/src/main/java/java/security/Signature.java +++ b/luni/src/main/java/java/security/Signature.java @@ -703,7 +703,7 @@ public abstract class Signature extends SignatureSpi { @Override public Object clone() throws CloneNotSupportedException { - SignatureSpi spi = (SignatureSpi) spiImpl.clone(); + SignatureSpi spi = spiImpl != null ? (SignatureSpi) spiImpl.clone() : null; return new SignatureImpl(getAlgorithm(), getProvider(), spi); } diff --git a/luni/src/test/java/org/apache/harmony/security/tests/java/security/Signature2Test.java b/luni/src/test/java/org/apache/harmony/security/tests/java/security/Signature2Test.java index 7886e3e..ad084e1 100644 --- a/luni/src/test/java/org/apache/harmony/security/tests/java/security/Signature2Test.java +++ b/luni/src/test/java/org/apache/harmony/security/tests/java/security/Signature2Test.java @@ -68,7 +68,17 @@ public class Signature2Test extends junit.framework.TestCase { * java.security.Signature#clone() */ public void test_clone() throws Exception { + // A Signature may be cloneable according to the API, in practice the implementation isn't + // once it has been initialized. Checking for runtime exceptions rather than useful + // behavior. Signature s = Signature.getInstance("DSA"); + Signature clone = (Signature) s.clone(); + assertNotNull(clone); + assertEquals(s.getAlgorithm(), clone.getAlgorithm()); + assertEquals(s.getProvider(), clone.getProvider()); + + KeyPair keyPair = getDsaKeys(); + s.initSign(keyPair.getPrivate()); try { s.clone(); fail(); |