Buggy code:
switch ( type ) { case Node . DOCUMENT_TYPE_NODE : { if ( DOMNormalizer . DEBUG_ND ) { System . out . println ( "==>normalizeNode:{doctype}" ) ; } break ; } case Node . ELEMENT_NODE : { if ( DOMNormalizer . DEBUG_ND ) { System . out . println ( ( "==>normalizeNode:{element}<seq2seq4repair_space>" + ( node . getNodeName ( ) ) ) ) ; } if ( ( ( ( fConfiguration . features ) & ( DOMConfigurationImpl . WELLFORMED ) ) != 0 ) && ( fDocument . isXMLVersionChanged ( ) ) ) { if ( fNamespaceValidation ) { wellformed = CoreDocumentImpl . isValidQName ( node . getPrefix ( ) , node . getLocalName ( ) , fDocument . isXML11Version ( ) ) ; } else { wellformed = CoreDocumentImpl . isXMLName ( node . getNodeName ( ) , fDocument . isXML11Version ( ) ) ; } if ( ! wellformed ) { String msg = DOMMessageFormatter . formatMessage ( DOM_DOMAIN , "wf-invalid-character-in-node-name" , new Object [ ] { "Element" , node . getNodeName ( ) } ) ; DOMNormalizer . reportDOMError ( fErrorHandler , fError , fLocator , msg , SEVERITY_ERROR , node , "wf-invalid-character-in-node-name" ) ; } } fNamespaceContext . pushContext ( ) ; fLocalNSBinder . reset ( ) ; ElementImpl elem = ( ( ElementImpl ) ( node ) ) ; if ( elem . needsSyncChildren ( ) ) { elem . synchronizeChildren ( ) ; } AttributeMap attributes = ( elem . hasAttributes ( ) ) ? ( ( AttributeMap ) ( elem . getAttributes ( ) ) ) : null ; if ( ( ( fConfiguration . features ) & ( DOMConfigurationImpl . NAMESPACES ) ) != 0 ) { namespaceFixUp ( elem , attributes ) ; } else { if ( attributes != null ) { for ( int i = 0 ; i < ( attributes . getLength ( ) ) ; ++ i ) { Attr attr = ( ( Attr ) ( attributes . item ( i ) ) ) ; attr . normalize ( ) ; if ( ( ( fConfiguration . features ) & ( DOMConfigurationImpl . WELLFORMED ) ) != 0 ) { DOMNormalizer . isAttrValueWF ( fErrorHandler , fError , fLocator , attributes , ( ( AttrImpl ) ( attr ) ) , attr . getValue ( ) , fDocument . isXML11Version ( ) ) ; if ( fDocument . isXMLVersionChanged ( ) ) { wellformed = CoreDocumentImpl . isXMLName ( node . getNodeName ( ) , fDocument . isXML11Version ( ) ) ; if ( ! wellformed ) { String msg = DOMMessageFormatter . formatMessage ( DOM_DOMAIN , "wf-invalid-character-in-node-name" , new Object [ ] { "Attr" , node . getNodeName ( ) } ) ; DOMNormalizer . reportDOMError ( fErrorHandler , fError , fLocator , msg , SEVERITY_ERROR , node , "wf-invalid-character-in-node-name" ) ; } } } } } } if ( ( fValidationHandler ) != null ) { fAttrProxy . setAttributes ( attributes , fDocument , elem ) ; updateQName ( elem , fQName ) ; fConfiguration . fErrorHandlerWrapper . fCurrentNode = node ; fCurrentNode = node ; fValidationHandler . startElement ( fQName , fAttrProxy , null ) ; } Node kid ; Node next ; for ( kid = elem . getFirstChild ( ) ; kid != null ; kid = next ) { next = kid . getNextSibling ( ) ; kid = normalizeNode ( kid ) ; if ( kid != null ) { next = kid ; } } if ( DOMNormalizer . DEBUG_ND ) { System . out . println ( ( ( "***The<seq2seq4repair_space>children<seq2seq4repair_space>of<seq2seq4repair_space>{" + ( node . getNodeName ( ) ) ) + "}<seq2seq4repair_space>are<seq2seq4repair_space>normalized" ) ) ; for ( kid = elem . getFirstChild ( ) ; kid != null ; kid = next ) { next = kid . getNextSibling ( ) ; System . out . println ( ( ( ( ( kid . getNodeName ( ) ) + "[" ) + ( kid . getNodeValue ( ) ) ) + "]" ) ) ; } } if ( ( fValidationHandler ) != null ) { updateQName ( elem , fQName ) ; fConfiguration . fErrorHandlerWrapper . fCurrentNode = node ; fCurrentNode = node ; fValidationHandler . endElement ( fQName , null ) ; } fNamespaceContext . popContext ( ) ; break ; } case Node . COMMENT_NODE : { if ( DOMNormalizer . DEBUG_ND ) { System . out . println ( "==>normalizeNode:{comments}" ) ; } if ( ( ( fConfiguration . features ) & ( DOMConfigurationImpl . COMMENTS ) ) == 0 ) { Node prevSibling = node . getPreviousSibling ( ) ; Node parent = node . getParentNode ( ) ; parent . removeChild ( node ) ; if ( ( prevSibling != null ) && ( ( prevSibling . getNodeType ( ) ) == ( Node . TEXT_NODE ) ) ) { Node nextSibling = prevSibling . getNextSibling ( ) ; if ( ( nextSibling != null ) && ( ( nextSibling . getNodeType ( ) ) == ( Node . TEXT_NODE ) ) ) { ( ( TextImpl ) ( nextSibling ) ) . insertData ( 0 , prevSibling . getNodeValue ( ) ) ; parent . removeChild ( prevSibling ) ; return nextSibling ; } } } else { if ( ( ( fConfiguration . features ) & ( DOMConfigurationImpl . WELLFORMED ) ) != 0 ) { String commentdata = ( ( Comment ) ( node ) ) . getData ( ) ; DOMNormalizer . isCommentWF ( fErrorHandler , fError , fLocator , commentdata , fDocument . isXML11Version ( ) ) ; } } break ; } case Node . ENTITY_REFERENCE_NODE : { if ( DOMNormalizer . DEBUG_ND ) { System . out . println ( ( "==>normalizeNode:{entityRef}<seq2seq4repair_space>" + ( node . getNodeName ( ) ) ) ) ; } if ( ( ( fConfiguration . features ) & ( DOMConfigurationImpl . ENTITIES ) ) == 0 ) { Node prevSibling = node . getPreviousSibling ( ) ; Node parent = node . getParentNode ( ) ; ( ( EntityReferenceImpl ) ( node ) ) . setReadOnly ( false , true ) ; expandEntityRef ( parent , node ) ; parent . removeChild ( node ) ; Node next = ( prevSibling != null ) ? prevSibling . getNextSibling ( ) : parent . getFirstChild ( ) ; <START_BUG> if ( ( ( prevSibling != null ) && ( ( prevSibling . getNodeType ( ) ) == ( Node . TEXT_NODE ) ) ) && ( ( next . getNodeType ( ) ) == ( Node . TEXT_NODE ) ) ) { <END_BUG>

Fix:
if ( ( ( ( prevSibling != null ) && ( next != null ) ) && ( ( prevSibling . getNodeType ( ) ) == ( Node . TEXT_NODE ) ) ) && ( ( next . getNodeType ( ) ) == ( Node . TEXT_NODE ) ) ) {