Skip to content

XContentBuilder to handle extended classes of java.util.Date #1465

Closed
@dawi

Description

@dawi

class: org.elasticsearch.common.xcontent.XContentBuilder
method: field(String name, Object value)

        } else if (type == Byte.class) {
            field(name, ((Byte) value).byteValue());
        } else if (type == Boolean.class) {
            field(name, ((Boolean) value).booleanValue());
        } else if (type == Date.class) {
            field(name, (Date) value);
        } else if (type == byte[].class) {

While it is ok to use type == xxx.class for final java classes I don't think it should be used for Date. Instead instanceof should be used so that the following method calls behave the same:

    xContentBuilder.field(field, (Date) dateValue)
    xContentBuilder.field(field, (Object) dateValue)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions