You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by sb...@apache.org on 2001/06/26 05:46:23 UTC
cvs commit: xml-xalan/java/src/org/apache/xalan/transformer TransformerHandlerImpl.java
sboag 01/06/25 20:46:22
Modified: java/src/org/apache/xalan/transformer
TransformerHandlerImpl.java
Log:
Call clearCoRoutine in fatalError, as part of the solution to not hang
when an error occurs.
If an error handler is not set, send a message to System.err. I
am somewhat undecided about this. I think it probably needs
more work.
Revision Changes Path
1.3 +44 -16 xml-xalan/java/src/org/apache/xalan/transformer/TransformerHandlerImpl.java
Index: TransformerHandlerImpl.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/transformer/TransformerHandlerImpl.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TransformerHandlerImpl.java 2001/06/12 19:15:28 1.2
+++ TransformerHandlerImpl.java 2001/06/26 03:46:22 1.3
@@ -141,6 +141,15 @@
protected void clearCoRoutine()
{
+ clearCoRoutine(null);
+ }
+
+ /**
+ * Do what needs to be done to shut down the CoRoutine management.
+ */
+ protected void clearCoRoutine(Exception ex)
+ {
+
if(m_dtm instanceof SAX2DTM)
{
if(DEBUG)
@@ -152,7 +161,7 @@
CoroutineSAXParser sp = (CoroutineSAXParser)m_contentHandler;
if(m_insideParse)
- sp.doMore(false, sax2dtm.getAppCoroutineID());
+ sp.doMore(false, sax2dtm.getAppCoroutineID());
}
sax2dtm.clearCoRoutine(true);
@@ -161,6 +170,18 @@
m_entityResolver = null;
m_errorHandler = null;
m_lexicalHandler = null;
+
+ if(null != ex)
+ {
+ Thread thread = m_transformer.getTransformThread();
+ if(null != thread)
+ {
+ thread.interrupt();
+ // Damn... we can't stop() it, since stop() is deprecated.
+ }
+ // I don't think we need to do anything else with the exception.
+ }
+
if(DEBUG)
System.out.println("...exiting clearCoRoutine");
}
@@ -359,12 +380,12 @@
//m_transformer.setTransformThread(listener);
m_transformer.setSourceTreeDocForThread(m_dtm.getDocument());
- int cpriority = Thread.currentThread().getPriority();
-
- // runTransformThread is equivalent with the 2.0.1 code,
- // except that the Thread may come from a pool.
- m_transformer.runTransformThread( cpriority );
-
+ int cpriority = Thread.currentThread().getPriority();
+
+ // runTransformThread is equivalent with the 2.0.1 code,
+ // except that the Thread may come from a pool.
+ m_transformer.runTransformThread( cpriority );
+
//listener.setDaemon(false);
//listener.start();
@@ -394,7 +415,7 @@
m_contentHandler.endDocument();
}
- m_transformer.waitTransformThread();
+ m_transformer.waitTransformThread();
/* Thread transformThread = m_transformer.getTransformThread();
if (null != transformThread)
@@ -618,13 +639,14 @@
public void warning(SAXParseException e) throws SAXException
{
- if (DEBUG)
- System.out.println("TransformerHandlerImpl#warning: " + e);
-
if (m_errorHandler != null)
{
m_errorHandler.warning(e);
}
+ else
+ {
+ System.err.println("TransformerHandlerImpl#warning: " + e);
+ }
}
/**
@@ -637,14 +659,17 @@
*/
public void error(SAXParseException e) throws SAXException
{
+ // %REVIEW% I don't think this should be called. -sb
+ // clearCoRoutine(e);
- if (DEBUG)
- System.out.println("TransformerHandlerImpl#error: " + e);
-
if (m_errorHandler != null)
{
m_errorHandler.error(e);
}
+ else
+ {
+ System.err.println("TransformerHandlerImpl#error: " + e);
+ }
}
/**
@@ -658,12 +683,15 @@
public void fatalError(SAXParseException e) throws SAXException
{
- if (DEBUG)
- System.out.println("TransformerHandlerImpl#fatalError: " + e);
+ clearCoRoutine(e);
if (m_errorHandler != null)
{
m_errorHandler.fatalError(e);
+ }
+ else
+ {
+ System.err.println("TransformerHandlerImpl#fatalError: " + e);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org