You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Sharmarke Aden (JIRA)" <ji...@apache.org> on 2012/11/09 17:00:13 UTC

[jira] [Created] (AVRO-1201) CLONE - GenericRecord.toString can produce invalid JSON

Sharmarke Aden created AVRO-1201:
------------------------------------

             Summary: CLONE - GenericRecord.toString can produce invalid JSON
                 Key: AVRO-1201
                 URL: https://issues.apache.org/jira/browse/AVRO-1201
             Project: Avro
          Issue Type: Bug
          Components: java
    Affects Versions: 1.4.1
            Reporter: Sharmarke Aden
            Assignee: Jay Kreps
             Fix For: 1.5.0


The GenericData.toString method can produce invalid JSON. The problem is that enums are printed without quotes, as in
{"emum_field":a}
instead of 
{"enum_field":"a"}




--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (AVRO-1201) CLONE - GenericRecord.toString can produce invalid JSON

Posted by "Sharmarke Aden (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AVRO-1201?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13494349#comment-13494349 ] 

Sharmarke Aden commented on AVRO-1201:
--------------------------------------

That works even better.
                
> CLONE - GenericRecord.toString can produce invalid JSON
> -------------------------------------------------------
>
>                 Key: AVRO-1201
>                 URL: https://issues.apache.org/jira/browse/AVRO-1201
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.7.2
>            Reporter: Sharmarke Aden
>            Assignee: Jay Kreps
>         Attachments: avro-1201.patch, Avro-1201-TestCase.tar.gz
>
>
> The GenericData.toString method can produce invalid JSON. The problem is that enums are printed without quotes, as in
> {"emum_field":a}
> instead of 
> {"enum_field":"a"}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (AVRO-1201) CLONE - GenericRecord.toString can produce invalid JSON

Posted by "Sharmarke Aden (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AVRO-1201?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sharmarke Aden updated AVRO-1201:
---------------------------------

    Attachment: Avro-1201-TestCase.tar.gz

Here is a test case that demonstrates the issue.
                
> CLONE - GenericRecord.toString can produce invalid JSON
> -------------------------------------------------------
>
>                 Key: AVRO-1201
>                 URL: https://issues.apache.org/jira/browse/AVRO-1201
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.7.2
>            Reporter: Sharmarke Aden
>            Assignee: Jay Kreps
>         Attachments: Avro-1201-TestCase.tar.gz
>
>
> The GenericData.toString method can produce invalid JSON. The problem is that enums are printed without quotes, as in
> {"emum_field":a}
> instead of 
> {"enum_field":"a"}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (AVRO-1201) CLONE - GenericRecord.toString can produce invalid JSON

Posted by "Sharmarke Aden (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AVRO-1201?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sharmarke Aden updated AVRO-1201:
---------------------------------

    Attachment: avro-1201.patch

Here's an updated patch that contains changes suggested by Doug.
                
> CLONE - GenericRecord.toString can produce invalid JSON
> -------------------------------------------------------
>
>                 Key: AVRO-1201
>                 URL: https://issues.apache.org/jira/browse/AVRO-1201
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.7.2
>            Reporter: Sharmarke Aden
>            Assignee: Jay Kreps
>         Attachments: avro-1201.patch, avro-1201.patch, Avro-1201-TestCase.tar.gz
>
>
> The GenericData.toString method can produce invalid JSON. The problem is that enums are printed without quotes, as in
> {"emum_field":a}
> instead of 
> {"enum_field":"a"}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (AVRO-1201) CLONE - GenericRecord.toString can produce invalid JSON

Posted by "Sharmarke Aden (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AVRO-1201?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13502250#comment-13502250 ] 

Sharmarke Aden commented on AVRO-1201:
--------------------------------------

Here is an updated patch that contains Doug's recommendations. I also took the liberty to change StringBuffer reference to StringBuiler and add Overridea annotations
                
> CLONE - GenericRecord.toString can produce invalid JSON
> -------------------------------------------------------
>
>                 Key: AVRO-1201
>                 URL: https://issues.apache.org/jira/browse/AVRO-1201
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.7.2
>            Reporter: Sharmarke Aden
>            Assignee: Jay Kreps
>         Attachments: avro-1201.patch, avro-1201.patch, Avro-1201-TestCase.tar.gz, vcs-diff4833874908267370412.patch
>
>
> The GenericData.toString method can produce invalid JSON. The problem is that enums are printed without quotes, as in
> {"emum_field":a}
> instead of 
> {"enum_field":"a"}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Resolved] (AVRO-1201) CLONE - GenericRecord.toString can produce invalid JSON

Posted by "Doug Cutting (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AVRO-1201?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Doug Cutting resolved AVRO-1201.
--------------------------------

       Resolution: Fixed
    Fix Version/s: 1.7.3
         Assignee: Sharmarke Aden  (was: Jay Kreps)

I committed this.
                
> CLONE - GenericRecord.toString can produce invalid JSON
> -------------------------------------------------------
>
>                 Key: AVRO-1201
>                 URL: https://issues.apache.org/jira/browse/AVRO-1201
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.7.2
>            Reporter: Sharmarke Aden
>            Assignee: Sharmarke Aden
>             Fix For: 1.7.3
>
>         Attachments: avro-1201.patch, avro-1201.patch, Avro-1201-TestCase.tar.gz, vcs-diff4833874908267370412.patch
>
>
> The GenericData.toString method can produce invalid JSON. The problem is that enums are printed without quotes, as in
> {"emum_field":a}
> instead of 
> {"enum_field":"a"}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (AVRO-1201) CLONE - GenericRecord.toString can produce invalid JSON

Posted by "Sharmarke Aden (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AVRO-1201?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13501236#comment-13501236 ] 

Sharmarke Aden commented on AVRO-1201:
--------------------------------------

I am wondering if this patch is acceptable and will get committed.
                
> CLONE - GenericRecord.toString can produce invalid JSON
> -------------------------------------------------------
>
>                 Key: AVRO-1201
>                 URL: https://issues.apache.org/jira/browse/AVRO-1201
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.7.2
>            Reporter: Sharmarke Aden
>            Assignee: Jay Kreps
>         Attachments: avro-1201.patch, avro-1201.patch, Avro-1201-TestCase.tar.gz
>
>
> The GenericData.toString method can produce invalid JSON. The problem is that enums are printed without quotes, as in
> {"emum_field":a}
> instead of 
> {"enum_field":"a"}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (AVRO-1201) CLONE - GenericRecord.toString can produce invalid JSON

Posted by "Sharmarke Aden (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AVRO-1201?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sharmarke Aden updated AVRO-1201:
---------------------------------

    Attachment: vcs-diff4833874908267370412.patch
    
> CLONE - GenericRecord.toString can produce invalid JSON
> -------------------------------------------------------
>
>                 Key: AVRO-1201
>                 URL: https://issues.apache.org/jira/browse/AVRO-1201
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.7.2
>            Reporter: Sharmarke Aden
>            Assignee: Jay Kreps
>         Attachments: avro-1201.patch, avro-1201.patch, Avro-1201-TestCase.tar.gz, vcs-diff4833874908267370412.patch
>
>
> The GenericData.toString method can produce invalid JSON. The problem is that enums are printed without quotes, as in
> {"emum_field":a}
> instead of 
> {"enum_field":"a"}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (AVRO-1201) CLONE - GenericRecord.toString can produce invalid JSON

Posted by "Doug Cutting (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AVRO-1201?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13494333#comment-13494333 ] 

Doug Cutting commented on AVRO-1201:
------------------------------------

I wonder if instead we should change this test to:
{code}
 isString(datum) || isEnum(datum)
{code}
Similarly, we should probably also change this method to use isFixed(), isMap(), isArray(), isBytes(), etc.
                
> CLONE - GenericRecord.toString can produce invalid JSON
> -------------------------------------------------------
>
>                 Key: AVRO-1201
>                 URL: https://issues.apache.org/jira/browse/AVRO-1201
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.7.2
>            Reporter: Sharmarke Aden
>            Assignee: Jay Kreps
>         Attachments: avro-1201.patch, Avro-1201-TestCase.tar.gz
>
>
> The GenericData.toString method can produce invalid JSON. The problem is that enums are printed without quotes, as in
> {"emum_field":a}
> instead of 
> {"enum_field":"a"}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (AVRO-1201) CLONE - GenericRecord.toString can produce invalid JSON

Posted by "Sharmarke Aden (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AVRO-1201?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sharmarke Aden updated AVRO-1201:
---------------------------------

    Fix Version/s:     (was: 1.5.0)
    
> CLONE - GenericRecord.toString can produce invalid JSON
> -------------------------------------------------------
>
>                 Key: AVRO-1201
>                 URL: https://issues.apache.org/jira/browse/AVRO-1201
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.7.2
>            Reporter: Sharmarke Aden
>            Assignee: Jay Kreps
>         Attachments: Avro-1201-TestCase.tar.gz
>
>
> The GenericData.toString method can produce invalid JSON. The problem is that enums are printed without quotes, as in
> {"emum_field":a}
> instead of 
> {"enum_field":"a"}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (AVRO-1201) CLONE - GenericRecord.toString can produce invalid JSON

Posted by "Sharmarke Aden (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AVRO-1201?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sharmarke Aden updated AVRO-1201:
---------------------------------

    Affects Version/s:     (was: 1.4.1)
                       1.7.2
    
> CLONE - GenericRecord.toString can produce invalid JSON
> -------------------------------------------------------
>
>                 Key: AVRO-1201
>                 URL: https://issues.apache.org/jira/browse/AVRO-1201
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.7.2
>            Reporter: Sharmarke Aden
>            Assignee: Jay Kreps
>         Attachments: Avro-1201-TestCase.tar.gz
>
>
> The GenericData.toString method can produce invalid JSON. The problem is that enums are printed without quotes, as in
> {"emum_field":a}
> instead of 
> {"enum_field":"a"}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (AVRO-1201) CLONE - GenericRecord.toString can produce invalid JSON

Posted by "Sharmarke Aden (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AVRO-1201?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13494073#comment-13494073 ] 

Sharmarke Aden commented on AVRO-1201:
--------------------------------------

GenericData toString() method doesn't check to see if "datum instanceof Enum" and appropriately handle enums. This results in an invalid json being produced similar to the one seen in AVRO-713.
                
> CLONE - GenericRecord.toString can produce invalid JSON
> -------------------------------------------------------
>
>                 Key: AVRO-1201
>                 URL: https://issues.apache.org/jira/browse/AVRO-1201
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.4.1
>            Reporter: Sharmarke Aden
>            Assignee: Jay Kreps
>             Fix For: 1.5.0
>
>
> The GenericData.toString method can produce invalid JSON. The problem is that enums are printed without quotes, as in
> {"emum_field":a}
> instead of 
> {"enum_field":"a"}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (AVRO-1201) CLONE - GenericRecord.toString can produce invalid JSON

Posted by "Sharmarke Aden (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AVRO-1201?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sharmarke Aden updated AVRO-1201:
---------------------------------

    Attachment: avro-1201.patch

Here is a patch for GenericData.java class that resolves the issue. I am not sure how you test patch without using the maven plugin and generating beans. 
                
> CLONE - GenericRecord.toString can produce invalid JSON
> -------------------------------------------------------
>
>                 Key: AVRO-1201
>                 URL: https://issues.apache.org/jira/browse/AVRO-1201
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.7.2
>            Reporter: Sharmarke Aden
>            Assignee: Jay Kreps
>         Attachments: avro-1201.patch, Avro-1201-TestCase.tar.gz
>
>
> The GenericData.toString method can produce invalid JSON. The problem is that enums are printed without quotes, as in
> {"emum_field":a}
> instead of 
> {"enum_field":"a"}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (AVRO-1201) GenericRecord.toString can produce invalid JSON

Posted by "Doug Cutting (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AVRO-1201?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Doug Cutting updated AVRO-1201:
-------------------------------

    Summary: GenericRecord.toString can produce invalid JSON  (was: CLONE - GenericRecord.toString can produce invalid JSON)
    
> GenericRecord.toString can produce invalid JSON
> -----------------------------------------------
>
>                 Key: AVRO-1201
>                 URL: https://issues.apache.org/jira/browse/AVRO-1201
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.7.2
>            Reporter: Sharmarke Aden
>            Assignee: Sharmarke Aden
>             Fix For: 1.7.3
>
>         Attachments: avro-1201.patch, avro-1201.patch, Avro-1201-TestCase.tar.gz, vcs-diff4833874908267370412.patch
>
>
> The GenericData.toString method can produce invalid JSON. The problem is that enums are printed without quotes, as in
> {"emum_field":a}
> instead of 
> {"enum_field":"a"}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (AVRO-1201) CLONE - GenericRecord.toString can produce invalid JSON

Posted by "Doug Cutting (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AVRO-1201?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13501524#comment-13501524 ] 

Doug Cutting commented on AVRO-1201:
------------------------------------

Sorry, I lost track of this one.

Some comments on the patch:
 - The toString() method should probably use isX() methods througout, so isMap(), isFixed(), isArray(), isString(), and isEnum().
 - I don't think we should change the definitions of isEnum() in GenericData and SpecificData.  If you're calling toString() on data that might include java.lang.Enum instances then you should use SpecificData or ReflectData, not GenericData.
 - We should add a test for the correct toString() of enums.
                
> CLONE - GenericRecord.toString can produce invalid JSON
> -------------------------------------------------------
>
>                 Key: AVRO-1201
>                 URL: https://issues.apache.org/jira/browse/AVRO-1201
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.7.2
>            Reporter: Sharmarke Aden
>            Assignee: Jay Kreps
>         Attachments: avro-1201.patch, avro-1201.patch, Avro-1201-TestCase.tar.gz
>
>
> The GenericData.toString method can produce invalid JSON. The problem is that enums are printed without quotes, as in
> {"emum_field":a}
> instead of 
> {"enum_field":"a"}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira