[ 
https://issues.apache.org/jira/browse/AVRO-1352?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13863900#comment-13863900
 ] 

Steve Roehrs commented on AVRO-1352:
------------------------------------

Sorry due to restrictions at my workplace I am unable to generate a patch and 
submit it, but I can describe the change required if someone else is able to 
submit it for me.

In NodeImpl.cc,  NodeFixed::PrintJson should look like this:

void
NodeFixed::PrintJson(std::ostream &os, int depth) const
{
  os << "{\n";
  os << indent(++depth) << "\"type\": \"fixed\",\n";
  printName(os, nameAttribute_.get(),depth);
  os << indent(depth) << "\"size\": << sizeAttribute_.get() << "\n";
  os << indent(--depth) << '}';
}

ie swap the lines around so that printName can print it's trailing ',' and be 
followed with the size: attribute.

It'd be great it this could make it into 1.7.6.  I'm guessing that not many C++ 
users are using fixed types, which is why the bug wasn't found earlier.




> Schema for fixed types corrupted when writing out in JSON format
> ----------------------------------------------------------------
>
>                 Key: AVRO-1352
>                 URL: https://issues.apache.org/jira/browse/AVRO-1352
>             Project: Avro
>          Issue Type: Bug
>          Components: c++
>    Affects Versions: 1.7.0, 1.7.1, 1.7.2, 1.7.3, 1.7.4
>            Reporter: Steve Roehrs
>            Priority: Minor
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> A change made in NodeImpl.cc under AVRO-1026 has introduced a bug that 
> corrupts JSON schemas when writing them to disk or dumping to a stream.  This 
> manifested when using DataFileWriter to generate a data file, and the schema 
> stored in the header was corrupted from the original schema provided.
>  
> e.g 
>  
> This:
> {noformat}
> {
>   “type”: “fixed”,
>   “name”: “Unsigned16”,
>   “size”: 2
> }
> {noformat}
>  
> Becomes this:
> {noformat}
> {
>   “type”: “fixed”,
>   “size”: 2,
>   “name” : “Unsigned16”,
> }
> {noformat}
> Note the extraneous comma after the ‘name’ attribute.
> The bug exists for Avro 'fixed' types, and has not been observed for other 
> types. A test case will be developed.
> The bug can be fixed by simply re-ordering the code in NodeFixed::printJson.



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Reply via email to