# HG changeset patch # Parent f60f42c440748ed82a7392c3b1e57e5c5fd0d825 RT-34541: ColorConverter should not assume the value is a String. It may be a Color. diff -r f60f42c44074 -r 50364f688b14 modules/graphics/src/main/java/com/sun/javafx/css/converters/ColorConverter.java --- a/modules/graphics/src/main/java/com/sun/javafx/css/converters/ColorConverter.java Wed Nov 27 09:40:35 2013 -0500 +++ b/modules/graphics/src/main/java/com/sun/javafx/css/converters/ColorConverter.java Wed Nov 27 12:53:55 2013 -0500 @@ -48,17 +48,28 @@ @Override public Color convert(ParsedValue value, Font font) { - String str = value.getValue(); - if (str == null || str.isEmpty() || "null".equals(str)) { + Object val = value.getValue(); + if (val == null) { return null; } - try { - return Color.web(str); - } catch (final IllegalArgumentException e) { - // TODO: use logger here - System.err.println("not a color: " + value); - return Color.BLACK; + + if (val instanceof Color) { + return (Color)val; } + + if (val instanceof String) { + String str = (String)val; + if (str.isEmpty() || "null".equals(str)) { + return null; + } + try { + return Color.web((String)val); + } catch (IllegalArgumentException iae) { + throw iae; + } + } + + throw new IllegalArgumentException("bad color value: " + val.toString()); } @Override