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

Rendering HTML code in JEditorPane throws NumberFormatException

    Details

    • Subcomponent:
    • Resolved In Build:
      b65
    • OS:
      windows_7

      Backports

        Description

        FULL PRODUCT VERSION :
        Java SE 7u17

        ADDITIONAL OS VERSION INFORMATION :
        Issue happens on Mac OSX, Windows XP, Windows 7 , Windows 8

        A DESCRIPTION OF THE PROBLEM :
        Trying to render html code inside a JEditorPane, I get NumberFormatException due to not clean code in rows attribute of frameset:
        <frameset rows= " 120px,* " frameborder= " 0 " border= " 0 " framespacing= " 0 " >
        <frame src= " / " scrolling= " auto " name= " entete " >
        <frame src= " / " scrolling= " auto " name= " detail " >
        </frameset>

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Run code. As you can see frame contains:
        rows= " 120px,* "
        which should be:
        rows= " 120,* "

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        The HTML is rendered
        ACTUAL -
        2013/02/19 22:43:34 ERROR - jmeter.JMeter: Uncaught exception: java.lang.NumberFormatException: For input string: " 120px "
        at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
        at java.lang.Integer.parseInt(Integer.java:458)
        at java.lang.Integer.parseInt(Integer.java:499)
        at javax.swing.text.html.FrameSetView.init(FrameSetView.java:122)
        at javax.swing.text.html.FrameSetView.layoutMajorAxis(FrameSetView.java:156)
        at javax.swing.text.BoxView.setSpanOnAxis(BoxView.java:313)
        at javax.swing.text.BoxView.layout(BoxView.java:692)
        at javax.swing.text.BoxView.setSize(BoxView.java:380)
        at javax.swing.text.BoxView.updateChildSizes(BoxView.java:349)
        at javax.swing.text.BoxView.setSpanOnAxis(BoxView.java:331)
        at javax.swing.text.BoxView.layout(BoxView.java:691)
        at javax.swing.text.BoxView.setSize(BoxView.java:380)
        at javax.swing.text.BoxView.updateChildSizes(BoxView.java:349)
        at javax.swing.text.BoxView.setSpanOnAxis(BoxView.java:331)
        at javax.swing.text.BoxView.layout(BoxView.java:691)
        at javax.swing.text.BoxView.setSize(BoxView.java:380)
        at javax.swing.plaf.basic.BasicTextUI$RootView.setSize(BasicTextUI.java:1703)
        at javax.swing.plaf.basic.BasicTextUI.getPreferredSize(BasicTextUI.java:901)
        at javax.swing.JComponent.getPreferredSize(JComponent.java:1642)
        at javax.swing.JEditorPane.getPreferredSize(JEditorPane.java:1412)
        at javax.swing.JViewport.getViewSize(JViewport.java:1066)
        at javax.swing.plaf.basic.BasicScrollPaneUI.syncScrollPaneWithViewport(BasicScrollPaneUI.java:265)
        at javax.swing.plaf.basic.BasicScrollPaneUI$Handler.viewportStateChanged(BasicScrollPaneUI.java:1067)
        at javax.swing.plaf.basic.BasicScrollPaneUI$Handler.stateChanged(BasicScrollPaneUI.java:1009)
        at javax.swing.JViewport.fireStateChanged(JViewport.java:1432)
        at javax.swing.JViewport.setView(JViewport.java:1038)
        at javax.swing.JScrollPane.setViewportView(JScrollPane.java:985)
        at org.apache.jmeter.visualizers.RenderAsHTML.showRenderedResponse(RenderAsHTML.java:107)
        at org.apache.jmeter.visualizers.RenderAsHTML.showRenderedResponse(RenderAsHTML.java:55)
        at org.apache.jmeter.visualizers.RenderAsHTML.renderResult(RenderAsHTML.java:51)
        at org.apache.jmeter.visualizers.ViewResultsFullVisualizer.valueChanged(ViewResultsFullVisualizer.java:253)
        at javax.swing.JTree.fireValueChanged(JTree.java:2820)
        at javax.swing.JTree$TreeSelectionRedirector.valueChanged(JTree.java:3191)
        at javax.swing.tree.DefaultTreeSelectionModel.fireValueChanged(DefaultTreeSelectionModel.java:629)
        at javax.swing.tree.DefaultTreeSelectionModel.notifyPathChange(DefaultTreeSelectionModel.java:1078)
        at javax.swing.tree.DefaultTreeSelectionModel.setSelectionPaths(DefaultTreeSelectionModel.java:287)
        at javax.swing.tree.DefaultTreeSelectionModel.setSelectionPath(DefaultTreeSelectionModel.java:170)
        at javax.swing.JTree.setSelectionPath(JTree.java:1598)
        at javax.swing.plaf.basic.BasicTreeUI.selectPathForEvent(BasicTreeUI.java:2311)
        at javax.swing.plaf.basic.BasicTreeUI$Handler.handleSelection(BasicTreeUI.java:3520)
        at javax.swing.plaf.basic.BasicTreeUI$Handler.mousePressed(BasicTreeUI.java:3459)
        at java.awt.Component.processMouseEvent(Component.java:6379)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3275)
        at java.awt.Component.processEvent(Component.java:6147)
        at java.awt.Container.processEvent(Container.java:2083)
        at java.awt.Component.dispatchEventImpl(Component.java:4744)
        at java.awt.Container.dispatchEventImpl(Container.java:2141)
        at java.awt.Component.dispatchEvent(Component.java:4572)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4619)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4277)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4210)
        at java.awt.Container.dispatchEventImpl(Container.java:2127)
        at java.awt.Window.dispatchEventImpl(Window.java:2489)
        at java.awt.Component.dispatchEvent(Component.java:4572)
        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:710)
        at java.awt.EventQueue.access$400(EventQueue.java:82)
        at java.awt.EventQueue$2.run(EventQueue.java:669)
        at java.awt.EventQueue$2.run(EventQueue.java:667)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
        at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98)
        at java.awt.EventQueue$3.run(EventQueue.java:683)
        at java.awt.EventQueue$3.run(EventQueue.java:681)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:680)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

        ERROR MESSAGES/STACK TRACES THAT OCCUR :
        Exception in thread " main " java.lang.NumberFormatException: For input string: " 120px "
        at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
        at java.lang.Integer.parseInt(Integer.java:458)
        at java.lang.Integer.parseInt(Integer.java:499)
        at javax.swing.text.html.FrameSetView.init(FrameSetView.java:122)
        at javax.swing.text.html.FrameSetView.layoutMajorAxis(FrameSetView.java:156)
        at javax.swing.text.BoxView.setSpanOnAxis(BoxView.java:313)
        at javax.swing.text.BoxView.layout(BoxView.java:692)
        at javax.swing.text.BoxView.setSize(BoxView.java:380)
        at javax.swing.text.BoxView.updateChildSizes(BoxView.java:349)
        at javax.swing.text.BoxView.setSpanOnAxis(BoxView.java:331)
        at javax.swing.text.BoxView.layout(BoxView.java:691)
        at javax.swing.text.BoxView.setSize(BoxView.java:380)
        at javax.swing.text.BoxView.updateChildSizes(BoxView.java:349)
        at javax.swing.text.BoxView.setSpanOnAxis(BoxView.java:331)
        at javax.swing.text.BoxView.layout(BoxView.java:691)
        at javax.swing.text.BoxView.setSize(BoxView.java:380)
        at javax.swing.plaf.basic.BasicTextUI$RootView.setSize(BasicTextUI.java:1703)
        at javax.swing.plaf.basic.BasicTextUI.getPreferredSize(BasicTextUI.java:906)
        at javax.swing.JComponent.getPreferredSize(JComponent.java:1642)
        at javax.swing.JEditorPane.getPreferredSize(JEditorPane.java:1412)
        at javax.swing.ScrollPaneLayout.layoutContainer(ScrollPaneLayout.java:769)
        at java.awt.Container.layout(Container.java:1419)
        at java.awt.Container.doLayout(Container.java:1408)
        at java.awt.Container.validateTree(Container.java:1505)
        at java.awt.Container.validateTree(Container.java:1511)
        at java.awt.Container.validateTree(Container.java:1511)
        at java.awt.Container.validateTree(Container.java:1511)
        at java.awt.Container.validateTree(Container.java:1511)
        at java.awt.Container.validate(Container.java:1478)
        at java.awt.Window.show(Window.java:862)
        at org.apache.jmeter.Bug.main(Bug.java:57)


        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        package org.apache.jmeter;

        import javax.swing.JEditorPane;
        import javax.swing.JFrame;
        import javax.swing.JScrollPane;
        import javax.swing.text.EditorKit;

        public class Bug {
            private static final String TEXT_HTML = " text/html " ;
            private static final EditorKit defaultHtmlEditor = JEditorPane
                    .createEditorKitForContentType(TEXT_HTML);

            public static void main(String[] args) {

                JEditorPane results = new JEditorPane();
                results.setEditable(false);
                results.setEditorKitForContentType(TEXT_HTML, defaultHtmlEditor);
                results.setContentType(TEXT_HTML);
                results.getDocument().putProperty( " IgnoreCharsetDirective " ,
                        Boolean.TRUE);
                try {
                    String html = " <html> "
                            + " <head> "
                            + " <meta http-equiv=\ " Content-Type\ " content=\ " text/html; charset=iso-8859-1\ " > "
                            + " <title></title> "
                            + " </head> "
                            + " <frameset rows=\ " 120px,*\ " frameborder=\ " 0\ " border=\ " 0\ " framespacing=\ " 0\ " > "
                            + " <frame src=\ " http://www.google.com/\ " scrolling=\ " auto\ " name=\ " entete\ " > "
                            + " <frame src=\ " http://www.google.com/\ " scrolling=\ " auto\ " name=\ " detail\ " > "
                            + " </frameset> " + " <noframes> " + " <body> " + " </body> "
                            + " </noframes> " + " </html> " ;
                    results.setText(html); // Bug can generate RTE
                } catch (Exception e) {
                    results.setContentType( " text/html " );
                    results.setText(e.getMessage());
                }
                JScrollPane scrollPane = new JScrollPane(results);
                JFrame f = new JFrame( " Bug " );
                f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                f.getContentPane().add(scrollPane);
                f.setSize(512, 342);
                f.show();
            }
        }
        ---------- END SOURCE ----------

          Activity

          Hide
          bvaidya Balchandra Vaidya added a comment -
          Here is a comment from the Submitter of this bug.

          On 11/19/14 08:53 PM, Philippe Mouawad wrote:
          > I don't see any progress on it , any chance it gets fixed ? I tested on Java 9, it is still there.
          Show
          bvaidya Balchandra Vaidya added a comment - Here is a comment from the Submitter of this bug. On 11/19/14 08:53 PM, Philippe Mouawad wrote: > I don't see any progress on it , any chance it gets fixed ? I tested on Java 9, it is still there.
          Hide
          vdyakov Victor Dyakov added a comment -
          The root cause:
          FrameSetView does not parse "px" units in rows and cols attributes.
          Suggested fix:
          "px" are parsed in the FrameSetView.init() method.
          Show
          vdyakov Victor Dyakov added a comment - The root cause: FrameSetView does not parse "px" units in rows and cols attributes. Suggested fix: "px" are parsed in the FrameSetView.init() method.
          Hide
          hgupdate HG Updates added a comment -
          URL: http://hg.openjdk.java.net/jdk9/client/jdk/rev/8e45c1f60155
          User: alexsch
          Date: 2015-04-29 15:53:36 +0000
          Show
          hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/client/jdk/rev/8e45c1f60155 User: alexsch Date: 2015-04-29 15:53:36 +0000
          Hide
          hgupdate HG Updates added a comment -
          URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/8e45c1f60155
          User: lana
          Date: 2015-05-20 16:35:40 +0000
          Show
          hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/8e45c1f60155 User: lana Date: 2015-05-20 16:35:40 +0000

            People

            • Assignee:
              vdyakov Victor Dyakov
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: