jkesselm 02/02/22 07:32:22
Modified: java/src/org/apache/xml/dtm/ref DTMManagerDefault.java
Log:
Make synchronized to address potential reentrancy issue in
XRTreeFrag.finalize(), as discussed in the Javadoc. This may
solve several outstanding bug reports regarding reuse of
Transformers and cache suppression in for-each.
Revision Changes Path
1.36 +29 -15
xml-xalan/java/src/org/apache/xml/dtm/ref/DTMManagerDefault.java
Index: DTMManagerDefault.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/DTMManagerDefault.java,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- DTMManagerDefault.java 6 Feb 2002 17:46:45 -0000 1.35
+++ DTMManagerDefault.java 22 Feb 2002 15:32:22 -0000 1.36
@@ -99,7 +99,21 @@
/**
* The default implementation for the DTMManager.
- */
+ *
+ * %REVIEW% There is currently a reentrancy issue, since the finalizer
+ * for XRTreeFrag (which runs in the GC thread) wants to call
+ * DTMManager.release(), and may do so at the same time that the main
+ * transformation thread is accessing the manager. Our current solution is
+ * to make most of the manager's methods <code>synchronized</code>.
+ * Early tests suggest that doing so is not causing a significant
+ * performance hit in Xalan. However, it should be noted that there
+ * is a possible alternative solution: rewrite release() so it merely
+ * posts a request for release onto a threadsafe queue, and explicitly
+ * process that queue on an infrequent basis during main-thread
+ * activity (eg, when getDTM() is invoked). The downside of that solution
+ * would be a greater delay before the DTM's storage is actually released
+ * for reuse.
+ * */
public class DTMManagerDefault extends DTMManager
{
@@ -139,7 +153,7 @@
* @param dtm Should be a valid reference to a DTM.
* @param id Integer DTM ID to be bound to this DTM
*/
- public void addDTM(DTM dtm, int id) { addDTM(dtm,id,0); }
+ synchronized public void addDTM(DTM dtm, int id) { addDTM(dtm,id,0); }
/**
@@ -152,7 +166,7 @@
* public DTM Handle. For the first DTM ID accessing each DTM, this is 0;
* for overflow addressing it will be a multiple of 1<<IDENT_DTM_NODE_BITS.
*/
- public void addDTM(DTM dtm, int id, int offset)
+ synchronized public void addDTM(DTM dtm, int id, int offset)
{
if(id>=IDENT_MAX_DTMS)
{
@@ -193,7 +207,7 @@
/**
* Get the first free DTM ID available. %OPT% Linear search is inefficient!
*/
- public int getFirstFreeDTMID()
+ synchronized public int getFirstFreeDTMID()
{
int n = m_dtms.length;
for (int i = 1; i < n; i++)
@@ -250,7 +264,7 @@
*
* @return a non-null DTM reference.
*/
- public DTM getDTM(Source source, boolean unique,
+ synchronized public DTM getDTM(Source source, boolean unique,
DTMWSFilter whiteSpaceFilter, boolean incremental,
boolean doIndexing)
{
@@ -491,7 +505,7 @@
*
* @return a valid DTM handle.
*/
- public int getDTMHandleFromNode(org.w3c.dom.Node node)
+ synchronized public int getDTMHandleFromNode(org.w3c.dom.Node node)
{
if(null == node)
throw new
IllegalArgumentException(XSLMessages.createMessage(XSLTErrorResources.ER_NODE_NON_NULL,
null)); //"node must be non-null for getDTMHandleFromNode!");
@@ -595,7 +609,7 @@
*
* @return non-null XMLReader reference ready to parse.
*/
- public XMLReader getXMLReader(Source inputSource)
+ synchronized public XMLReader getXMLReader(Source inputSource)
{
try
@@ -677,7 +691,7 @@
*
* @return a reference to the DTM object containing this node.
*/
- public DTM getDTM(int nodeHandle)
+ synchronized public DTM getDTM(int nodeHandle)
{
try
{
@@ -702,7 +716,7 @@
*
* @return The ID, or -1 if the DTM doesn't belong to this manager.
*/
- public int getDTMIdentity(DTM dtm)
+ synchronized public int getDTMIdentity(DTM dtm)
{
// Shortcut using DTMDefaultBase's extension hooks
// %REVIEW% Should the lookup be part of the basic DTM API?
@@ -743,7 +757,7 @@
* @return true if the DTM was released, false if shouldHardDelete was set
* and we decided not to.
*/
- public boolean release(DTM dtm, boolean shouldHardDelete)
+ synchronized public boolean release(DTM dtm, boolean shouldHardDelete)
{
if(DEBUG)
{
@@ -794,7 +808,7 @@
*
* NEEDSDOC (createDocumentFragment) @return
*/
- public DTM createDocumentFragment()
+ synchronized public DTM createDocumentFragment()
{
try
@@ -825,7 +839,7 @@
*
* NEEDSDOC (createDTMIterator) @return
*/
- public DTMIterator createDTMIterator(int whatToShow, DTMFilter filter,
+ synchronized public DTMIterator createDTMIterator(int whatToShow,
DTMFilter filter,
boolean entityReferenceExpansion)
{
@@ -842,7 +856,7 @@
*
* NEEDSDOC (createDTMIterator) @return
*/
- public DTMIterator createDTMIterator(String xpathString,
+ synchronized public DTMIterator createDTMIterator(String xpathString,
PrefixResolver presolver)
{
@@ -858,7 +872,7 @@
*
* NEEDSDOC (createDTMIterator) @return
*/
- public DTMIterator createDTMIterator(int node)
+ synchronized public DTMIterator createDTMIterator(int node)
{
/** @todo: implement this org.apache.xml.dtm.DTMManager abstract method
*/
@@ -874,7 +888,7 @@
*
* NEEDSDOC (createDTMIterator) @return
*/
- public DTMIterator createDTMIterator(Object xpathCompiler, int pos)
+ synchronized public DTMIterator createDTMIterator(Object xpathCompiler,
int pos)
{
/** @todo: implement this org.apache.xml.dtm.DTMManager abstract method
*/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]