When a TransformerHandler is used the actual writing of the final elements is delegated to an XML serializer such as ToHTMLStream which extends ToStream.
When ToStream.characters is called with zero length it returns immediately and does not close the start tag of the current element, and ToStream.endElement checks whether the start tag is open to determine whether or not to close as <title/> or <title></title>.
It seems the code brought over from the xalan project to the JDK was locked down quite a bit during the transition. When using xalan directly an alternate XML serializer can be specified via XSLT or other means , but in the JDK that functionality seems to have been removed as TransletOutputHandlerFactory.getSerializationHandler has ToHTMLStream hard-coded.
Additionally, ToHTMLStream is declared as final and the majority of the classes which one would normally extend to use a different TransletOutputHandlerFactory are internal, so a proper solution would likely involve depending on xalan directly or duplicating a whole lot of code, neither of which is ideal.
As a workaround, a ExpandedTitleContentHandler content handler decorator was added which checks for the previous fix for this issue, a call to characters(new char, 0, 0) for the title element, and if present changes the length to 1 then catches the expected ArrayIndexOutOfBoundsException thrown by ToStream.characters.
The result is that the title start tag is closed since the check for zero length passes and no character writing is attempted.
TikaCLI was modified to wrap the transformer handler returned by SAXTransformerFactory for the html output method, so only handling of the title tag for HTML output will be affected by the change.
In the event that this approach has adverse effects for those using XML serializers other than those present in the JDK, the change to TikaCLI can be reverted or made an option.
Those calling Tika programmatically will need to wrap their transformer handlers in a ExpandedTitleContentHandler as well, i.e.:
SAXTransformerFactory factory = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
TransformerHandler handler = factory.newTransformerHandler();
return new ExpandedTitleContentHandler(handler);
Resolved in r1423538.