avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Rosenstrauch (JIRA)" <j...@apache.org>
Subject [jira] Created: (AVRO-612) Schema.toString() strips out field docs
Date Fri, 13 Aug 2010 00:01:20 GMT
Schema.toString() strips out field docs
---------------------------------------

                 Key: AVRO-612
                 URL: https://issues.apache.org/jira/browse/AVRO-612
             Project: Avro
          Issue Type: Bug
    Affects Versions: 1.3.3
            Reporter: David Rosenstrauch
            Priority: Minor


Although avro can successfully parse schema text that contains a "doc" on a Schema.Field,
when a Schema containing a field doc is serialized (via Schema.toString()) the doc does not
get written.

The following JUnit test case demonstrates this problem:
{code:title=TestAvroFieldDocSerialization.java|borderStyle=solid}
import junit.framework.TestCase;

import org.apache.avro.Schema;

public class TestAvroFieldDocSerialization extends TestCase {

	public void testAvroFieldDocSerialization() {
		String schemaStr =
			"{"+
			"	\"name\": \"Rec\","+
			"	\"type\": \"record\","+
			"	\"fields\" : ["+
			"		{\"name\": \"f\", \"type\": \"int\", \"doc\": \"test\"}"+
			"	]"+
			"}";
		Schema schema = Schema.parse(schemaStr);
		verifyFieldDoc(schema);

		schemaStr = schema.toString();
		schema = Schema.parse(schemaStr);
		verifyFieldDoc(schema);
	}

	private void verifyFieldDoc(Schema schema) {
		Schema.Field field = schema.getField("f");
		assertEquals("test", field.doc());
	}
}
{code}

Note that the first call to verifyFieldDoc() succeeds, while the second one fails.  They should
both succeed (in my opinion).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message