[ http://issues.apache.org/jira/browse/XALANJ-1901?page=all ]
Brian Minchau updated XALANJ-1901:
----------------------------------
Version: Latest Development Code
(was: 2.6)
> DTMManagerDefault.getDTM() incorrectly returns null
> ---------------------------------------------------
>
> Key: XALANJ-1901
> URL: http://issues.apache.org/jira/browse/XALANJ-1901
> Project: XalanJ2
> Type: Bug
> Components: DTM
> Versions: Latest Development Code
> Environment: Operating System: Other
> Platform: All
> Reporter: John J. Barton
> Assignee: Xalan Developers Mailing List
>
> The following suggested fix for
> org.apache.xml.dtm.ref.XTMManagerDefault.getDTM()
> relates to Bug 22217
> NullPointerException in TransformerImpl.run() when reusing XMLFilter object
> http://nagoya.apache.org/bugzilla/show_bug.cgi?id=22217
> =======================================================================
> In the interface file we read:
> /*
> * $Id: DTMManager.java,v 1.18 2004/02/23 10:29:36 aruny Exp $
> */
> package org.apache.xml.dtm;
> ....
> /**
> * Get the instance of DTM that "owns" a node handle.
> *
> * @param nodeHandle the nodeHandle.
> *
> * @return a non-null DTM reference.
> */
> public abstract DTM getDTM(int nodeHandle);
> ======================================================================
> Note in particular that the return is *non-null*.
> In the implementation we read:
> ======================================================================
> /*
> * $Id: DTMManagerDefault.java,v 1.51 2004/02/16 23:06:11 minchau Exp $
> */
> package org.apache.xml.dtm.ref;
> ....
> /**
> * Return the DTM object containing a representation of this node.
> *
> * @param nodeHandle DTM Handle indicating which node to retrieve
> *
> * @return a reference to the DTM object containing this node.
> */
> synchronized public DTM getDTM(int nodeHandle)
> {
> try
> {
> // Performance critical function.
> return m_dtms[nodeHandle >>> IDENT_DTM_NODE_BITS];
> }
> catch(java.lang.ArrayIndexOutOfBoundsException e)
> {
> if(nodeHandle==DTM.NULL)
> return null; // Accept as a special
> case.
> else
> throw e; // Programming error;
> want to know about it.
> }
> }
> ====================================================================
> In addition to the "special case", the array m_dtms can have "null"
> values that are returned, contrary to the interface documentation.
> Callers of getDTM() use the return value without checking for null,
> for example
> =======================================================================
> /*
> * $Id: TransformerImpl.java,v 1.158 2004/02/23 21:33:14 igorh Exp $
> */
> package org.apache.xalan.transformer;
> ...
> public boolean applyTemplateToNode(ElemTemplateElement xslInstruction, //
> xsl:apply-templates or xsl:for-each
> ElemTemplate template, int child)
> throws TransformerException
> {
> DTM dtm = m_xcontext.getDTM(child);
> short nodeType = dtm.getNodeType(child); <<<<<<<<<<<< NPE!!
>
> boolean isDefaultTextRule = false;
> boolean isApplyImports = false;
> ...
> =================================================================
> In my opinion getDTM() should be thus:
> ==================================================================
> /**
> * Return the DTM object containing a representation of this node.
> *
> * @param nodeHandle DTM Handle indicating which node to retrieve
> *
> * @return a reference to the DTM object containing this node.
> */
> synchronized public DTM getDTM(int nodeHandle)
> {
> // Performance critical function.
> DTM dtm = m_dtms[nodeHandle >>> IDENT_DTM_NODE_BITS];
> if (dtm != null) {
> return dtm;
> } else {
> throw new TransformerException(this.getClass().getName()
> +" Document Table contains null pointer for
> nodeHandle="+nodeHandle);
> }
> }
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]