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

REGRESSION: CSS cause NPE for unknown colours

XMLWordPrintable

    • beta
    • x86
    • windows_2000

        Name: js151677 Date: 08/17/2004


        FULL PRODUCT VERSION :
        java version "1.5.0-beta2"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b51)
        Java HotSpot(TM) Client VM (build 1.5.0-beta2-b51, mixed mode, sharing)

        ADDITIONAL OS VERSION INFORMATION :
        Microsoft Windows 2000 [Version 5.00.2195]

        A DESCRIPTION OF THE PROBLEM :
        CSS cause NPE for unknown colours

        The CSS spec says that unknown values need to be ignored.

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        run code

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        the default colour to be used

        ERROR MESSAGES/STACK TRACES THAT OCCUR :
        Exception in thread "main" java.lang.NullPointerException

        at javax.swing.text.html.CSS.stringToColor(CSS.java:1049)

        at javax.swing.text.html.CSS$ColorValue.parseCssValue(CSS.java:2001)

        at javax.swing.text.html.CSS.getInternalCSSValue(CSS.java:532)

        at javax.swing.text.html.CSS.addInternalCSSValue(CSS.java:516)

        at javax.swing.text.html.StyleSheet.addCSSAttribute(StyleSheet.java:465)

        at javax.swing.text.html.StyleSheet$CssParser.handleValue(StyleSheet.java:3146)

        at javax.swing.text.html.CSSParser.parseDeclaration(CSSParser.java:341)

        at javax.swing.text.html.CSSParser.parseDeclarationBlock(CSSParser.java:308)

        at javax.swing.text.html.CSSParser.parseRuleSet(CSSParser.java:255)

        at javax.swing.text.html.CSSParser.getNextStatement(CSSParser.java:161)

        at javax.swing.text.html.CSSParser.parse(CSSParser.java:136)

        at javax.swing.text.html.StyleSheet$CssParser.parse(StyleSheet.java:3068)

        at javax.swing.text.html.StyleSheet.addRule(StyleSheet.java:273)

        at javax.swing.text.html.HTMLDocument$HTMLReader.addCSSRules(HTMLDocument.java:3374)

        at javax.swing.text.html.HTMLDocument$HTMLReader$HeadAction.end(HTMLDocument.java:2526)

        at javax.swing.text.html.HTMLDocument$HTMLReader.handleEndTag(HTMLDocument.java:2264)

        at javax.swing.text.html.parser.DocumentParser.handleEndTag(DocumentParser.java:223)

        at javax.swing.text.html.parser.Parser.parse(Parser.java:2132)

        at javax.swing.text.html.parser.DocumentParser.parse(DocumentParser.java:105)

        at javax.swing.text.html.parser.ParserDelegator.parse(ParserDelegator.java:73)

        at javax.swing.text.html.HTMLEditorKit.read(HTMLEditorKit.java:230)

        at javax.swing.JEditorPane.setText(JEditorPane.java:1311)

        at javax.swing.JEditorPane.<init>(JEditorPane.java:264)
        1, mixed mode, sharing)

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        import javax.swing.*;

        public class Test {
          public static void main(String[] args) {
            JFrame frame = new JFrame();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.add(new JEditorPane("text/html",
              "<HTML>" +
                "<HEAD>" +
                  "<TITLE>CSS Test</title>" +
                  "<STYLE TYPE=\"text/css\">" +
                    "H1 { color: orange }" +
                  "</style>" +
                "</head>" +
                "<BODY>" +
                  "<H1>This might be orange or the default colour</h1>" +
                "</body>" +
              "</html>"));
            frame.setSize(500, 500);
            frame.setVisible(true);
          }
        }
        ---------- END SOURCE ----------

        Release Regression From : 1.4.2_05
        The above release value was the last known release where this
        bug was known to work. Since then there has been a regression.

        (Incident Review ID: 297283)
        ======================================================================
        ###@###.### 2004-09-09

              peterz Peter Zhelezniakov
              jssunw Jitender S (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: