JDK-8054018 : [macosx] HTMLDocument containing a table renders incorrectly.
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 7u60
  • Priority: P3
  • Status: Resolved
  • Resolution: Duplicate
  • OS: os_x
  • CPU: x86
  • Submitted: 2014-07-30
  • Updated: 2014-08-14
  • Resolved: 2014-08-14
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9Resolved
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.7.0_65"
Java(TM) SE Runtime Environment (build 1.7.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Darwin cthulhu.local 13.3.0 Darwin Kernel Version 13.3.0: Tue Jun  3 21:27:35 PDT 2014; root:xnu-2422.110.17~1/RELEASE_X86_64 x86_64

A DESCRIPTION OF THE PROBLEM :
I have a program which creates an HTMLDocument containing a table.

With java version 1.7.0_55, the table renders correctly.
With java version 1.7.0_60 or later - including the current released 1.7.0_65 and 1.8 - the table is duplicated and rendered incorrectly.

REGRESSION.  Last worked in version 7u55

ADDITIONAL REGRESSION INFORMATION: 
java version "1.7.0_65"
Java(TM) SE Runtime Environment (build 1.7.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
bash-3.2$ setjdk 1.7.0_65
bash-3.2$ java -version
java version "1.7.0_65"
Java(TM) SE Runtime Environment (build 1.7.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)
bash-3.2$ javac Test.java
bash-3.2$ java Test

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
A frame will pop up titled "Test HTML Frame"

In 1.7.0_55, there is an HTML table in it with three columns and three rows: one header row and two data rows.
ACTUAL -
A frame will pop up titled "Test HTML Frame"

In 1.7.0_65, the aforementioned table is shown.
It is followed by a duplicate of the same table and an additional table where each cell contains the cell data twice on separate lines.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.io.StringWriter;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.text.Element;
import javax.swing.text.html.HTMLDocument;
import javax.swing.text.html.HTMLEditorKit;

public abstract class Test
{
	public static void generateRow( final StringBuilder buffer, final String tag, final String [] elts )
	{
		String open = "<" + tag + ">";
		String close = "</" + tag + ">";
		buffer.append( "<tr>" );
		for ( String elt : elts ) {
			buffer.append( open );
			buffer.append( elt );
			buffer.append( close );
		}
		buffer.append( "</tr>" );
	}

	public static void generateTable( final StringBuilder buffer )
	{
		buffer.append( "<table border=1>" );
		Test.generateRow( buffer, "th", new String[] { "Column 1", "Column 2", "Column 3" } );
		Test.generateRow( buffer, "td", new String[] { "abc", "def", "ghi" } );
		Test.generateRow( buffer, "td", new String[] { "123", "456", "789" } );
		buffer.append( "</table>" );
	}

	public static String generateHTML()
	{
		StringBuilder buffer = new StringBuilder();
		Test.generateTable( buffer );
		return buffer.toString();
	}

	private static void printHTML( final HTMLDocument doc )
        {
		HTMLEditorKit kit = new HTMLEditorKit();
		StringWriter writer = new StringWriter();
		try
		{
			kit.write(writer, doc, 0, doc.getLength());
		}
		catch ( Exception e )
		{
		}
		String s = writer.toString();
		System.out.println( "New HTML = \"" + s + "\"" );
	}

	private static void createAndShowGUI()
        {
		// Create and set up the window.

		JFrame frame = new JFrame();
		frame.setTitle( "Test HTML Frame" );
		frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );

		Container contents = frame.getContentPane();

		JEditorPane pane = new JEditorPane();
		pane.setContentType( "text/html" );
		pane.setEditable( false );

		HTMLDocument currentHTML = (HTMLDocument) pane.getDocument();

		// Test.printHTML( currentHTML );

		Element contentElement = currentHTML.getDefaultRootElement();
		while ( !contentElement.isLeaf() ) {
			contentElement = contentElement.getElement( contentElement.getElementCount() - 1 );
		}

		String text = Test.generateHTML();
		try
		{
			currentHTML.insertAfterEnd( contentElement, text );
		}
		catch ( Exception e )
		{
		}

		// Test.printHTML( currentHTML );

		contents.add( pane, BorderLayout.CENTER );

		//Display the window.
		frame.pack();
		frame.setVisible(true);
	}

	/**
	 * The main method.
	 */

	public static final void main( final String[] args )
	{
		javax.swing.SwingUtilities.invokeLater(
			new Runnable() {
				public void run() {
					createAndShowGUI();
				}
			} );

		while (true ) {
			try
			{
				Thread.sleep( 1000 );
			}
			catch ( InterruptedException e )
			{
				break;
			}
		}
	}
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
None found.


Comments
This one and JDK-8048110 have the same root cause. So this will be fixed by the changes for JDK-8048110. Closing as dupe of JDK-8048110.
14-08-2014

This is a regression from the fix JDK-8024395
12-08-2014

- this is an issue reported against 7(7u), - there are now affected version 9 filed for this issue - 7u issues are transferred to Sustaining Nevertheless if someone have a report against 9 - please reopen and add affectedVersion 9 or 7u specific escalations might be reopen to Sustaining
10-08-2014

With java version 1.7.0_55, the table renders correctly. With java version 1.7.0_60 or later - including the current released 1.7.0_65 and 1.8 - the table is duplicated and rendered incorrectly.
06-08-2014

is it reproducible on 8 or 9 ?
31-07-2014