You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by mu...@apache.org on 2013/05/22 21:37:27 UTC

svn commit: r1485370 - in /santuario/xml-security-java/trunk/src: main/java/org/apache/jcp/xml/dsig/internal/dom/DOMKeyInfo.java test/java/javax/xml/crypto/test/dsig/keyinfo/KeyInfoTest.java

Author: mullan
Date: Wed May 22 19:37:26 2013
New Revision: 1485370

URL: http://svn.apache.org/r1485370
Log:
DOMKeyInfo.marshal should throw NPE when parent is null per KeyInfo.marshal API spec.

Modified:
    santuario/xml-security-java/trunk/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMKeyInfo.java
    santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/keyinfo/KeyInfoTest.java

Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMKeyInfo.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMKeyInfo.java?rev=1485370&r1=1485369&r2=1485370&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMKeyInfo.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMKeyInfo.java Wed May 22 19:37:26 2013
@@ -144,7 +144,10 @@ public final class DOMKeyInfo extends Ba
     public void marshal(XMLStructure parent, XMLCryptoContext context)
         throws MarshalException
     {
-        if (parent == null || !(parent instanceof javax.xml.crypto.dom.DOMStructure)) {
+        if (parent == null) {
+            throw new NullPointerException("parent is null");
+        }
+        if (!(parent instanceof javax.xml.crypto.dom.DOMStructure)) {
             throw new ClassCastException("parent must be of type DOMStructure");
         }
 

Modified: santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/keyinfo/KeyInfoTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/keyinfo/KeyInfoTest.java?rev=1485370&r1=1485369&r2=1485370&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/keyinfo/KeyInfoTest.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/keyinfo/KeyInfoTest.java Wed May 22 19:37:26 2013
@@ -115,8 +115,8 @@ public class KeyInfoTest extends org.jun
             (Collections.singletonList(fac.newKeyName("foo")), "keyid");
         try {
             ki.marshal(null, null);
-            fail("Should raise a ClassCastException");
-        } catch (ClassCastException npe) {}
+            fail("Should raise a NullPointerException");
+        } catch (NullPointerException npe) {}
 
         DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
         dbf.setNamespaceAware(true);