[
https://issues.apache.org/jira/browse/AVRO-720?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12976111#action_12976111
]
Doug Cutting commented on AVRO-720:
-----------------------------------
If we change a generated field to be something like:
java.util.List<? extends java.lang.CharSequence> strings;
Then we can do things like:
x.strings = new ArrayList<Utf8>();
But we can no longer do things like:
x.strings.add(new Utf8("foo"));
Rather, this would have to become:
((List<Utf8)x.strings).add(new Utf8("foo"));
The problem as I understand it is that List<? extends java.lang.CharSequence>
declares all elements to be of some unknown type that implements CharSequence.
Utf8 may or may not be that type, so we cannot directly insert without casting.
So, on the whole, I think we're better of keeping the field declared with:
java.util.List<java.lang.CharSequence> strings;
This means we need to create instances with:
x.strings = new ArrayList<CharSequence>();
Which isn't really so bad, is it?
> Generated code for arrays should accept extensions of array content type
> ------------------------------------------------------------------------
>
> Key: AVRO-720
> URL: https://issues.apache.org/jira/browse/AVRO-720
> Project: Avro
> Issue Type: Improvement
> Components: java
> Reporter: Jeff Hammerbacher
> Assignee: Doug Cutting
> Fix For: 1.5.0
>
> Attachments: AVRO-720.patch
>
>
> Discovered when I upgraded a server from 1.3 to 1.4: trying to stuff a
> GenericData.Array<Utf8> object into a List<CharSequence> does not work; Avro
> should generate List<? implements CharSequence> instead. The same holds for
> other array types.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.