JDK-8078268 : javax.swing.text.html.parser.Parser parseScript incorrectly optimized
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 8,9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_7
  • CPU: x86_64
  • Submitted: 2015-04-20
  • Updated: 2022-04-14
  • Resolved: 2016-05-13
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 8 JDK 9
8u112Fixed 9 b124Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]


A DESCRIPTION OF THE PROBLEM :
Parsing an HTML-page containing large scripts (with comments) is painfully slow after updating to Java 8. 

Parsing a page that took <1s before now takes >5minutes!

Looking at the difference between Jav 7 and Java 8 versions the culprit is most likely the "optimization" added. (Adding 'insideComment' and keeping it up to date by repeatedly copying the whole string looks like a *very* bad idea).

REGRESSION.  Last worked in version 7u80

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Code inspection should be enought to see that this is an issue. 

But otherwise prepare a Parser.parse request targeting for example http://site.soccer.betfair.com/Menu.do?timeZone=Europe/Stockholm&region=GBR&brand=betfair&locale=sv


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The HTML being parsed in a few seconds.
ACTUAL -
The HTML being parsed, but you have to get a cup of coffee before it is done (5-7 minutes on my machine).

REPRODUCIBILITY :
This bug can be reproduced always.


Comments
URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/57ce9ac31faf User: lana Date: 2016-06-22 19:53:10 +0000
22-06-2016

URL: http://hg.openjdk.java.net/jdk9/client/jdk/rev/57ce9ac31faf User: mcherkas Date: 2016-05-13 11:37:39 +0000
13-05-2016

not a regression for 9 since introduced even in 8
04-04-2016

Looks like a regression from JDK-7011777
21-04-2015

import javax.swing.*; import javax.swing.text.html.HTMLDocument; import javax.swing.text.html.HTMLEditorKit; import java.io.FileReader; public class HTMLTest{ public static void main(String[] args) throws Exception { JEditorPane ep = new JEditorPane("text/html", ""); HTMLDocument doc = (HTMLDocument) ep.getDocument(); System.out.println("Parser started"); long s = System.currentTimeMillis(); doc.getParser().parse(new FileReader("test.html"), new HTMLEditorKit.ParserCallback(), false); System.out.println("Parser completed in " + (System.currentTimeMillis() - s)/1000 + "s"); } } Parser started Parser completed in 230s
21-04-2015