[jira] [Commented] (AVRO-2438) SpecificData.deepCopy() cannot be used with URI fields

2020-05-26 Thread Hudson (Jira)


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

Hudson commented on AVRO-2438:
--

FAILURE: Integrated in Jenkins build AvroJava #892 (See 
[https://builds.apache.org/job/AvroJava/892/])
AVRO-2438:SpecificData.deepCopy() cannot be used with java-class fields 
(github: 
[https://github.com/apache/avro/commit/3bf7356376ff176d17960814fad62f13f66c3a4d])
* (edit) lang/java/ipc/src/test/java/org/apache/avro/generic/TestDeepCopy.java
* (edit) lang/java/avro/src/main/java/org/apache/avro/generic/GenericData.java
* (edit) lang/java/avro/src/main/java/org/apache/avro/specific/SpecificData.java


> SpecificData.deepCopy() cannot be used with URI fields
> --
>
> Key: AVRO-2438
> URL: https://issues.apache.org/jira/browse/AVRO-2438
> Project: Apache Avro
>  Issue Type: Bug
>  Components: java
>Affects Versions: 1.9.0, 1.8.2
>Reporter: Sebastian J.
>Assignee: Zezeng Wang
>Priority: Major
> Fix For: 1.10.0
>
>
> Having a schema fragment like this:
> {code:java}
> {
> "name": "ownerId",
> "type": [
>   "null",
>   {
> "type": "string",
> "java-class": "java.net.URI"
>   }
> ],
> "default": null
> }{code}
> can be perfectly deserialized in a generated POJO with
> {code:java}
> @org.apache.avro.specific.AvroGenerated
> public class MyAvroDataObject extends 
> org.apache.avro.specific.SpecificRecordBase implements 
> org.apache.avro.specific.SpecificRecord {
> ...
> @Deprecated public java.net.URI ownerId;{code}
> as 
> {{GenericDatumReader.readString(Object, Schema, Decoder)}} uses via the 
> {{stringClassCache}} with 
> {code:java}
> {"type":"string","java-class":"java.net.URI"}=class java.net.URI{code}
> The {{URI}} class itself to rehydrate the value via {{newInstanceFromString}}.
>  
> On the other hand, {{deepCopy}} only considers the schema-type of the field 
> and turns in {{org.apache.avro.generic.GenericData.deepCopy(Schema, T)}}
> the {{URI}} value into an {{org.apache.avro.util.Utf8}} via the {{String}} 
> case which then causes a {{ClassCastException}}:
> {noformat}
> java.lang.ClassCastException: org.apache.avro.util.Utf8 cannot be cast to 
> java.net.URI
>   at com.example.MyAvroDataObject.put(MyAvroDataObject.java:104)
>   at org.apache.avro.generic.GenericData.setField(GenericData.java:660)
>   at org.apache.avro.generic.GenericData.setField(GenericData.java:677)
>   at org.apache.avro.generic.GenericData.deepCopy(GenericData.java:1082)
>   at org.apache.avro.generic.GenericData.deepCopy(GenericData.java:1102)
>   at 
> org.apache.avro.generic.GenericData.deepCopy(GenericData.java:1080){noformat}
>  
> The following dirty hack seems to avoid the issue - but is not in sync with 
> the {{stringClassCache}} which should be consulted, too:
> {code:java}
> case STRING:
>   // Strings are immutable
>   if (value instanceof String) {
> return (T)value;
>   }
>   // Dirty Harry 9 3/4 start
>   // URIs are immutable and are probably modeled as an URI itself 
>   // TODO: Check with stringClassCache & the schema
>   else if ((value instanceof URI)
> && URI.class.getName().equals(schema.getProp("java-class"))
> ) {
> return (T)value;
>   }
>   // Dirt Harry 9 3/4 end
>   // Some CharSequence subclasses are mutable, so we still need to make
>   // a copy
>   else if (value instanceof Utf8) {
> // Utf8 copy constructor is more efficient than converting
> // to string and then back to Utf8
> return (T)new Utf8((Utf8)value);
>   }
>   return (T)new Utf8(value.toString());
> {code}
>  
> Also tried with Avro {{1.10-SNAPSHOT}} of 2019-06-20 / 
> {{2d3b1fe7efd865639663ba785877182e7e038c45}} due to 
> [https://github.com/apache/avro/pull/329] - but the issue remains.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (AVRO-2438) SpecificData.deepCopy() cannot be used with URI fields

2020-05-26 Thread ASF subversion and git services (Jira)


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

ASF subversion and git services commented on AVRO-2438:
---

Commit 3bf7356376ff176d17960814fad62f13f66c3a4d in avro's branch 
refs/heads/master from Zezeng Wang
[ https://gitbox.apache.org/repos/asf?p=avro.git;h=3bf7356 ]

AVRO-2438:SpecificData.deepCopy() cannot be used with java-class fields (#703)

* AVRO-2438:SpecificData.deepCopy() cannot be used with java-class fields

* Update spotless check

* Modify comment

* AVRO-2438:Increase the deepcopy support of java-key-class

Co-authored-by: Daniel Kulp 

> SpecificData.deepCopy() cannot be used with URI fields
> --
>
> Key: AVRO-2438
> URL: https://issues.apache.org/jira/browse/AVRO-2438
> Project: Apache Avro
>  Issue Type: Bug
>  Components: java
>Affects Versions: 1.9.0, 1.8.2
>Reporter: Sebastian J.
>Assignee: Zezeng Wang
>Priority: Major
>
> Having a schema fragment like this:
> {code:java}
> {
> "name": "ownerId",
> "type": [
>   "null",
>   {
> "type": "string",
> "java-class": "java.net.URI"
>   }
> ],
> "default": null
> }{code}
> can be perfectly deserialized in a generated POJO with
> {code:java}
> @org.apache.avro.specific.AvroGenerated
> public class MyAvroDataObject extends 
> org.apache.avro.specific.SpecificRecordBase implements 
> org.apache.avro.specific.SpecificRecord {
> ...
> @Deprecated public java.net.URI ownerId;{code}
> as 
> {{GenericDatumReader.readString(Object, Schema, Decoder)}} uses via the 
> {{stringClassCache}} with 
> {code:java}
> {"type":"string","java-class":"java.net.URI"}=class java.net.URI{code}
> The {{URI}} class itself to rehydrate the value via {{newInstanceFromString}}.
>  
> On the other hand, {{deepCopy}} only considers the schema-type of the field 
> and turns in {{org.apache.avro.generic.GenericData.deepCopy(Schema, T)}}
> the {{URI}} value into an {{org.apache.avro.util.Utf8}} via the {{String}} 
> case which then causes a {{ClassCastException}}:
> {noformat}
> java.lang.ClassCastException: org.apache.avro.util.Utf8 cannot be cast to 
> java.net.URI
>   at com.example.MyAvroDataObject.put(MyAvroDataObject.java:104)
>   at org.apache.avro.generic.GenericData.setField(GenericData.java:660)
>   at org.apache.avro.generic.GenericData.setField(GenericData.java:677)
>   at org.apache.avro.generic.GenericData.deepCopy(GenericData.java:1082)
>   at org.apache.avro.generic.GenericData.deepCopy(GenericData.java:1102)
>   at 
> org.apache.avro.generic.GenericData.deepCopy(GenericData.java:1080){noformat}
>  
> The following dirty hack seems to avoid the issue - but is not in sync with 
> the {{stringClassCache}} which should be consulted, too:
> {code:java}
> case STRING:
>   // Strings are immutable
>   if (value instanceof String) {
> return (T)value;
>   }
>   // Dirty Harry 9 3/4 start
>   // URIs are immutable and are probably modeled as an URI itself 
>   // TODO: Check with stringClassCache & the schema
>   else if ((value instanceof URI)
> && URI.class.getName().equals(schema.getProp("java-class"))
> ) {
> return (T)value;
>   }
>   // Dirt Harry 9 3/4 end
>   // Some CharSequence subclasses are mutable, so we still need to make
>   // a copy
>   else if (value instanceof Utf8) {
> // Utf8 copy constructor is more efficient than converting
> // to string and then back to Utf8
> return (T)new Utf8((Utf8)value);
>   }
>   return (T)new Utf8(value.toString());
> {code}
>  
> Also tried with Avro {{1.10-SNAPSHOT}} of 2019-06-20 / 
> {{2d3b1fe7efd865639663ba785877182e7e038c45}} due to 
> [https://github.com/apache/avro/pull/329] - but the issue remains.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (AVRO-2438) SpecificData.deepCopy() cannot be used with URI fields

2020-05-26 Thread ASF subversion and git services (Jira)


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

ASF subversion and git services commented on AVRO-2438:
---

Commit 3bf7356376ff176d17960814fad62f13f66c3a4d in avro's branch 
refs/heads/master from Zezeng Wang
[ https://gitbox.apache.org/repos/asf?p=avro.git;h=3bf7356 ]

AVRO-2438:SpecificData.deepCopy() cannot be used with java-class fields (#703)

* AVRO-2438:SpecificData.deepCopy() cannot be used with java-class fields

* Update spotless check

* Modify comment

* AVRO-2438:Increase the deepcopy support of java-key-class

Co-authored-by: Daniel Kulp 

> SpecificData.deepCopy() cannot be used with URI fields
> --
>
> Key: AVRO-2438
> URL: https://issues.apache.org/jira/browse/AVRO-2438
> Project: Apache Avro
>  Issue Type: Bug
>  Components: java
>Affects Versions: 1.9.0, 1.8.2
>Reporter: Sebastian J.
>Assignee: Zezeng Wang
>Priority: Major
>
> Having a schema fragment like this:
> {code:java}
> {
> "name": "ownerId",
> "type": [
>   "null",
>   {
> "type": "string",
> "java-class": "java.net.URI"
>   }
> ],
> "default": null
> }{code}
> can be perfectly deserialized in a generated POJO with
> {code:java}
> @org.apache.avro.specific.AvroGenerated
> public class MyAvroDataObject extends 
> org.apache.avro.specific.SpecificRecordBase implements 
> org.apache.avro.specific.SpecificRecord {
> ...
> @Deprecated public java.net.URI ownerId;{code}
> as 
> {{GenericDatumReader.readString(Object, Schema, Decoder)}} uses via the 
> {{stringClassCache}} with 
> {code:java}
> {"type":"string","java-class":"java.net.URI"}=class java.net.URI{code}
> The {{URI}} class itself to rehydrate the value via {{newInstanceFromString}}.
>  
> On the other hand, {{deepCopy}} only considers the schema-type of the field 
> and turns in {{org.apache.avro.generic.GenericData.deepCopy(Schema, T)}}
> the {{URI}} value into an {{org.apache.avro.util.Utf8}} via the {{String}} 
> case which then causes a {{ClassCastException}}:
> {noformat}
> java.lang.ClassCastException: org.apache.avro.util.Utf8 cannot be cast to 
> java.net.URI
>   at com.example.MyAvroDataObject.put(MyAvroDataObject.java:104)
>   at org.apache.avro.generic.GenericData.setField(GenericData.java:660)
>   at org.apache.avro.generic.GenericData.setField(GenericData.java:677)
>   at org.apache.avro.generic.GenericData.deepCopy(GenericData.java:1082)
>   at org.apache.avro.generic.GenericData.deepCopy(GenericData.java:1102)
>   at 
> org.apache.avro.generic.GenericData.deepCopy(GenericData.java:1080){noformat}
>  
> The following dirty hack seems to avoid the issue - but is not in sync with 
> the {{stringClassCache}} which should be consulted, too:
> {code:java}
> case STRING:
>   // Strings are immutable
>   if (value instanceof String) {
> return (T)value;
>   }
>   // Dirty Harry 9 3/4 start
>   // URIs are immutable and are probably modeled as an URI itself 
>   // TODO: Check with stringClassCache & the schema
>   else if ((value instanceof URI)
> && URI.class.getName().equals(schema.getProp("java-class"))
> ) {
> return (T)value;
>   }
>   // Dirt Harry 9 3/4 end
>   // Some CharSequence subclasses are mutable, so we still need to make
>   // a copy
>   else if (value instanceof Utf8) {
> // Utf8 copy constructor is more efficient than converting
> // to string and then back to Utf8
> return (T)new Utf8((Utf8)value);
>   }
>   return (T)new Utf8(value.toString());
> {code}
>  
> Also tried with Avro {{1.10-SNAPSHOT}} of 2019-06-20 / 
> {{2d3b1fe7efd865639663ba785877182e7e038c45}} due to 
> [https://github.com/apache/avro/pull/329] - but the issue remains.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (AVRO-2438) SpecificData.deepCopy() cannot be used with URI fields

2020-05-26 Thread ASF subversion and git services (Jira)


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

ASF subversion and git services commented on AVRO-2438:
---

Commit 3bf7356376ff176d17960814fad62f13f66c3a4d in avro's branch 
refs/heads/master from Zezeng Wang
[ https://gitbox.apache.org/repos/asf?p=avro.git;h=3bf7356 ]

AVRO-2438:SpecificData.deepCopy() cannot be used with java-class fields (#703)

* AVRO-2438:SpecificData.deepCopy() cannot be used with java-class fields

* Update spotless check

* Modify comment

* AVRO-2438:Increase the deepcopy support of java-key-class

Co-authored-by: Daniel Kulp 

> SpecificData.deepCopy() cannot be used with URI fields
> --
>
> Key: AVRO-2438
> URL: https://issues.apache.org/jira/browse/AVRO-2438
> Project: Apache Avro
>  Issue Type: Bug
>  Components: java
>Affects Versions: 1.9.0, 1.8.2
>Reporter: Sebastian J.
>Assignee: Zezeng Wang
>Priority: Major
>
> Having a schema fragment like this:
> {code:java}
> {
> "name": "ownerId",
> "type": [
>   "null",
>   {
> "type": "string",
> "java-class": "java.net.URI"
>   }
> ],
> "default": null
> }{code}
> can be perfectly deserialized in a generated POJO with
> {code:java}
> @org.apache.avro.specific.AvroGenerated
> public class MyAvroDataObject extends 
> org.apache.avro.specific.SpecificRecordBase implements 
> org.apache.avro.specific.SpecificRecord {
> ...
> @Deprecated public java.net.URI ownerId;{code}
> as 
> {{GenericDatumReader.readString(Object, Schema, Decoder)}} uses via the 
> {{stringClassCache}} with 
> {code:java}
> {"type":"string","java-class":"java.net.URI"}=class java.net.URI{code}
> The {{URI}} class itself to rehydrate the value via {{newInstanceFromString}}.
>  
> On the other hand, {{deepCopy}} only considers the schema-type of the field 
> and turns in {{org.apache.avro.generic.GenericData.deepCopy(Schema, T)}}
> the {{URI}} value into an {{org.apache.avro.util.Utf8}} via the {{String}} 
> case which then causes a {{ClassCastException}}:
> {noformat}
> java.lang.ClassCastException: org.apache.avro.util.Utf8 cannot be cast to 
> java.net.URI
>   at com.example.MyAvroDataObject.put(MyAvroDataObject.java:104)
>   at org.apache.avro.generic.GenericData.setField(GenericData.java:660)
>   at org.apache.avro.generic.GenericData.setField(GenericData.java:677)
>   at org.apache.avro.generic.GenericData.deepCopy(GenericData.java:1082)
>   at org.apache.avro.generic.GenericData.deepCopy(GenericData.java:1102)
>   at 
> org.apache.avro.generic.GenericData.deepCopy(GenericData.java:1080){noformat}
>  
> The following dirty hack seems to avoid the issue - but is not in sync with 
> the {{stringClassCache}} which should be consulted, too:
> {code:java}
> case STRING:
>   // Strings are immutable
>   if (value instanceof String) {
> return (T)value;
>   }
>   // Dirty Harry 9 3/4 start
>   // URIs are immutable and are probably modeled as an URI itself 
>   // TODO: Check with stringClassCache & the schema
>   else if ((value instanceof URI)
> && URI.class.getName().equals(schema.getProp("java-class"))
> ) {
> return (T)value;
>   }
>   // Dirt Harry 9 3/4 end
>   // Some CharSequence subclasses are mutable, so we still need to make
>   // a copy
>   else if (value instanceof Utf8) {
> // Utf8 copy constructor is more efficient than converting
> // to string and then back to Utf8
> return (T)new Utf8((Utf8)value);
>   }
>   return (T)new Utf8(value.toString());
> {code}
>  
> Also tried with Avro {{1.10-SNAPSHOT}} of 2019-06-20 / 
> {{2d3b1fe7efd865639663ba785877182e7e038c45}} due to 
> [https://github.com/apache/avro/pull/329] - but the issue remains.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)