[JIRA] Updated: (JXT-87) Code in AbstractSignableXMLObject etc unnecessarily calls NodeList which is thread-unsafe
Scott Cantor (JIRA)
noreply at shibboleth.net
Wed Oct 24 14:22:07 EDT 2012
[ https://issues.shibboleth.net/jira/browse/JXT-87?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Scott Cantor updated JXT-87:
----------------------------
Fix Version/s: 1.4.0
> Code in AbstractSignableXMLObject etc unnecessarily calls NodeList which is thread-unsafe
> -------------------------------------------------------------------------------------------
>
> Key: JXT-87
> URL: https://issues.shibboleth.net/jira/browse/JXT-87
> Project: XMLTooling - Java
> Issue Type: Bug
> Reporter: anli.shundi at idp.protectnetwork.org
> Assignee: Brent Putman
> Fix For: 1.4.0
>
>
> AbstractSignableXMLObject and other classes iterate over all DOM children by using the NodeList. This pattern is thread-unsafe since the DOM implementation will create a cache which will be inconsistent if accessible concurrently. Switching to the simpler getFirstChild() getNextSibling() is safer and even faster since no cache is created. The cache is useful for doing random access. All use-cases in XMLTooling seem to instead iterate over _all_ children.
> New code in above class.
> {code}
> @Override
> public boolean isSigned() {
> Element domElement = getDOM();
> if (domElement == null) {
> return false;
> }
> for(Node childElement = domElement.getFirstChild(); childElement != null; childElement = childElement.getNextSibling()) {
> if (childElement.getNodeType() != Node.ELEMENT_NODE) {
> continue;
> }
> if (XMLConstants.XMLSIG_NS.equals(childElement.getNamespaceURI())
> && Signature.DEFAULT_ELEMENT_LOCAL_NAME.equals(childElement.getLocalName())) {
> return true;
> }
> }
> return false;
> }
> {code}
> Similar pattern in {{AbstractXMLObjectUnmarshaller}} 's {{unmarshall(Element domElement)}} and {{XMLHelper}} 's
> {code}getChildElements(Element)
> getChildElementsByTagName(Element, String)
> getChildElementsByTagNameNS(Element, String, String)
> getElementContentAsQName(Element)
> getFirstChildElement(Node)
> rootNamespaces(Element, Element){code}
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the commits
mailing list