Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
dawi opened this issue Nov 14, 2011 · 2 comments
Closed

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

dawi opened this issue Nov 14, 2011 · 2 comments

Comments

@dawi
Copy link

dawi commented Nov 14, 2011

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)
@kimchy
Copy link
Member

kimchy commented Nov 15, 2011

Is that because of classes that extend Date, like java.sql.Date? Cause it will only happen for that case, what you posted works well.

@dawi
Copy link
Author

dawi commented Nov 15, 2011

Yes exactly. Forgot to mention that.

@kimchy kimchy closed this as completed in b8fe999 Nov 15, 2011
dadoonet pushed a commit to dadoonet/elasticsearch that referenced this issue Nov 16, 2011
mute pushed a commit to mute/elasticsearch that referenced this issue Jul 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants