Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8078268

javax.swing.text.html.parser.Parser parseScript incorrectly optimized

    Details

    • Subcomponent:
    • Resolved In Build:
      b124
    • CPU:
      x86_64
    • OS:
      windows_7

      Backports

        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.

        1. test.html
          642 kB
          Anton Nashatyrev

          Issue Links

            Activity

            Hide
            anashaty Anton Nashatyrev (Inactive) added a comment -
            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
            Show
            anashaty Anton Nashatyrev (Inactive) added a comment - 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
            Hide
            anashaty Anton Nashatyrev (Inactive) added a comment -
            Looks like a regression from JDK-7011777
            Show
            anashaty Anton Nashatyrev (Inactive) added a comment - Looks like a regression from JDK-7011777
            Hide
            vdyakov Victor Dyakov added a comment -
            not a regression for 9 since introduced even in 8
            Show
            vdyakov Victor Dyakov added a comment - not a regression for 9 since introduced even in 8
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk9/client/jdk/rev/57ce9ac31faf
            User: mcherkas
            Date: 2016-05-13 11:37:39 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/client/jdk/rev/57ce9ac31faf User: mcherkas Date: 2016-05-13 11:37:39 +0000
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/57ce9ac31faf
            User: lana
            Date: 2016-06-22 19:53:10 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/57ce9ac31faf User: lana Date: 2016-06-22 19:53:10 +0000

              People

              • Assignee:
                mcherkas Mikhail Cherkasov (Inactive)
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: