Buggy code:
public abstract class BaseMarkupSerializer implements DOMSerializer , Serializer , ContentHandler , DTDHandler , DocumentHandler , DeclHandler , LexicalHandler { private int _lastPrintable = 126 ; private ElementState [ ] _elementStates ; private int _elementStateCount ; private Vector _preRoot ; protected boolean _started ; private boolean _prepared ; protected Hashtable _prefixes ; protected String _docTypePublicId ; protected String _docTypeSystemId ; protected OutputFormat _format ; protected Printer _printer ; protected boolean _indenting ; private Writer _writer ; private OutputStream _output ; protected BaseMarkupSerializer ( OutputFormat format ) { } public DocumentHandler asDocumentHandler ( ) throws IOException { } public ContentHandler asContentHandler ( ) throws IOException { } public DOMSerializer asDOMSerializer ( ) throws IOException { } public void setOutputByteStream ( OutputStream output ) { } public void setOutputCharStream ( Writer writer ) { } public void setOutputFormat ( OutputFormat format ) { } public boolean reset ( ) { } private void prepare ( ) throws IOException { } public void serialize ( Element elem ) throws IOException { } public void serialize ( DocumentFragment frag ) throws IOException { } public void serialize ( Document doc ) throws IOException { } public void characters ( char [ ] chars , int start , int length ) { } public void ignorableWhitespace ( char [ ] chars , int start , int length ) { } public void processingInstruction ( String target , String code ) { } public void comment ( char [ ] chars , int start , int length ) { } public void comment ( String text ) { StringBuffer buffer ; int index ; ElementState state ; state = content ( ) ; buffer = new StringBuffer ( 40 ) ; index = text . indexOf ( "-->" ) ; if ( index >= 0 ) buffer . append ( "<!--" ) . append ( text . substring ( 0 , index ) ) . append ( "-->" ) ; else buffer . append ( "<!--" ) . append ( text ) . append ( "-->" ) ; if ( isDocumentState ( ) ) { if ( ( _preRoot ) == null ) _preRoot = new Vector ( ) ; _preRoot . addElement ( buffer . toString ( ) ) ; } else { _printer . indent ( ) ; <START_BUG> printText ( buffer . toString ( ) , false , false ) ; <END_BUG> _printer . unindent ( ) ; } } public void startCDATA ( ) { } public void endCDATA ( ) { } public void startNonEscaping ( ) { } public void endNonEscaping ( ) { } public void startPreserving ( ) { } public void endPreserving ( ) { } public void endDocument ( ) throws SAXException { } public void startEntity ( String name ) { } public void endEntity ( String name ) { } public void setDocumentLocator ( Locator locator ) { } public void skippedEntity ( String name ) throws SAXException { } public void startPrefixMapping ( String prefix , String uri ) throws SAXException { } public void endPrefixMapping ( String prefix ) throws SAXException { } public void startDTD ( String name , String publicId , String systemId ) { } public void endDTD ( ) { } public void elementDecl ( String name , String model ) { } public void attributeDecl ( String eName , String aName , String type , String valueDefault , String value ) { } public void internalEntityDecl ( String name , String value ) { } public void externalEntityDecl ( String name , String publicId , String systemId ) { } public void unparsedEntityDecl ( String name , String publicId , String systemId , String notationName ) { } public void notationDecl ( String name , String publicId , String systemId ) { } protected void serializeNode ( Node node ) { } protected ElementState content ( ) { } protected void characters ( String text ) { } protected abstract String getEntityRef ( char ch ) { } protected abstract void serializeElement ( Element elem ) { } protected void serializePreRoot ( ) { } protected final void printText ( char [ ] chars , int start , int length , boolean preserveSpace , boolean unescaped ) { } protected final void printText ( String text , boolean preserveSpace , boolean unescaped ) { } protected void printDoctypeURL ( String url ) { } protected void printEscaped ( char ch ) { } protected void printEscaped ( String source ) { } protected ElementState getElementState ( ) { } protected ElementState enterElementState ( String namespaceURI , String localName , String rawName , boolean preserveSpace ) { } protected ElementState leaveElementState ( ) { } protected boolean isDocumentState ( ) { } protected String getPrefix ( String namespaceURI ) { } }

Fix:
printText ( buffer . toString ( ) , false , true ) ;