You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mr...@apache.org on 2006/05/29 05:53:02 UTC

svn commit: r410017 - in /xerces/java/trunk/src/org/apache/xml/serialize: BaseMarkupSerializer.java DOMSerializerImpl.java

Author: mrglavas
Date: Sun May 28 20:53:02 2006
New Revision: 410017

URL: http://svn.apache.org/viewvc?rev=410017&view=rev
Log:
Fixing a bug. If the LSSerializer fails in the middle of serialization
we must ensure that its internal state is cleared so that it can be
reused. If this isn't done, the serializer may throw an exception
which complains that the serializer is already in use.

Modified:
    xerces/java/trunk/src/org/apache/xml/serialize/BaseMarkupSerializer.java
    xerces/java/trunk/src/org/apache/xml/serialize/DOMSerializerImpl.java

Modified: xerces/java/trunk/src/org/apache/xml/serialize/BaseMarkupSerializer.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xml/serialize/BaseMarkupSerializer.java?rev=410017&r1=410016&r2=410017&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xml/serialize/BaseMarkupSerializer.java (original)
+++ xerces/java/trunk/src/org/apache/xml/serialize/BaseMarkupSerializer.java Sun May 28 20:53:02 2006
@@ -1773,7 +1773,11 @@
     {
         return _elementStateCount == 0;
     }
-
+    
+    /** Clears document state. **/
+    final void clearDocumentState() {
+        _elementStateCount = 0;
+    }
 
     /**
      * Returns the namespace prefix for the specified URI.

Modified: xerces/java/trunk/src/org/apache/xml/serialize/DOMSerializerImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xml/serialize/DOMSerializerImpl.java?rev=410017&r1=410016&r2=410017&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xml/serialize/DOMSerializerImpl.java (original)
+++ xerces/java/trunk/src/org/apache/xml/serialize/DOMSerializerImpl.java Sun May 28 20:53:02 2006
@@ -508,16 +508,19 @@
                 }
                 throw new LSException(LSException.SERIALIZE_ERR, msg);
             }
-        } catch (LSException lse) {
+        } 
+        catch (LSException lse) {
             // Rethrow LSException.
             throw lse;
-        } catch (RuntimeException e) {
+        } 
+        catch (RuntimeException e) {
             if (e == DOMNormalizer.abort){
                 // stopped at user request
                 return null;
             }
             throw (LSException) DOMUtil.createLSException(LSException.SERIALIZE_ERR, e).fillInStackTrace();       
-        } catch (IOException ioe) {
+        } 
+        catch (IOException ioe) {
             // REVISIT: A generic IOException doesn't provide enough information
             // to determine that the serialized document is too large to fit
             // into a string. This could have thrown for some other reason. -- mrglavas
@@ -527,6 +530,9 @@
                 new Object[] { ioe.getMessage()});
             throw new DOMException(DOMException.DOMSTRING_SIZE_ERR,msg);
         }
+        finally {
+            ser.clearDocumentState();
+        }
         return destination.toString();
     }
 
@@ -754,7 +760,8 @@
                 ser.serialize((Element) node);
             else
                 return false;
-        } catch( UnsupportedEncodingException ue) {
+        } 
+        catch( UnsupportedEncodingException ue) {
             if (ser.fDOMErrorHandler != null) {
                 DOMErrorImpl error = new DOMErrorImpl();
                 error.fException = ue;
@@ -768,16 +775,19 @@
                     DOMMessageFormatter.SERIALIZER_DOMAIN, 
                     "unsupported-encoding", null));			
 			//return false;
-        } catch (LSException lse) {
+        } 
+        catch (LSException lse) {
             // Rethrow LSException.
             throw lse;
-        } catch (RuntimeException e) {
+        } 
+        catch (RuntimeException e) {
             if (e == DOMNormalizer.abort){
                 // stopped at user request
                 return false;
             }
             throw (LSException) DOMUtil.createLSException(LSException.SERIALIZE_ERR, e).fillInStackTrace();
-        } catch (Exception e) {
+        } 
+        catch (Exception e) {
             if (ser.fDOMErrorHandler != null) {
                 DOMErrorImpl error = new DOMErrorImpl();
                 error.fException = e;
@@ -788,6 +798,9 @@
             }
             throw (LSException) DOMUtil.createLSException(LSException.SERIALIZE_ERR, e).fillInStackTrace();
         }
+        finally {
+            ser.clearDocumentState();
+        }
         return true;
 
     } //write
@@ -886,16 +899,19 @@
                 ser.serialize((Element) node);
             else
                 return false;
-        } catch (LSException lse) {
+        } 
+        catch (LSException lse) {
             // Rethrow LSException.
             throw lse;
-        } catch (RuntimeException e) {
+        } 
+        catch (RuntimeException e) {
             if (e == DOMNormalizer.abort){
                 // stopped at user request
                 return false;
             }
             throw (LSException) DOMUtil.createLSException(LSException.SERIALIZE_ERR, e).fillInStackTrace();
-        } catch (Exception e) {
+        } 
+        catch (Exception e) {
             if (ser.fDOMErrorHandler != null) {
                 DOMErrorImpl error = new DOMErrorImpl();
                 error.fException = e;
@@ -904,6 +920,9 @@
                 ser.fDOMErrorHandler.handleError(error);
             }
             throw (LSException) DOMUtil.createLSException(LSException.SERIALIZE_ERR, e).fillInStackTrace();
+        }
+        finally {
+            ser.clearDocumentState();
         }
         return true;
     } //writeURI



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org