[jira] [Updated] (AVRO-2808) Java: ReflectData incorrectly handles hidden fields

2020-05-08 Thread Andy Le (Jira)


 [ 
https://issues.apache.org/jira/browse/AVRO-2808?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Andy Le updated AVRO-2808:
--
Issue Type: Improvement  (was: Bug)

> Java: ReflectData incorrectly handles hidden fields
> ---
>
> Key: AVRO-2808
> URL: https://issues.apache.org/jira/browse/AVRO-2808
> Project: Apache Avro
>  Issue Type: Improvement
>  Components: java
>Affects Versions: 1.9.2
>Reporter: Andy Le
>Assignee: Andy Le
>Priority: Major
>
> Hi guys,
> I've got the following test:
> {code:java}
> public ReflectTest{
>   public class Definition {
> public Map tokens;
>   }
>   public enum Type {
> A,
> B,
> C
>   }
>   @Test
>   public void testAvro2805() {
> Schema schema = ReflectData.get().getSchema(Definition.class);
> final String schemaString = schema.toString(true);
> System.out.println(schemaString);
>   }
> }
> {code}
> When I ran the test, an exception is raised:
> {noformat}
> org.apache.avro.SchemaParseException: Illegal character in: this$0
>   at org.apache.avro.Schema.validateName(Schema.java:1530)
>   at org.apache.avro.Schema.access$400(Schema.java:87)
>   at org.apache.avro.Schema$Field.(Schema.java:518)
>   at org.apache.avro.Schema$Field.(Schema.java:557)
>   at 
> org.apache.avro.reflect.ReflectData.createSchema(ReflectData.java:683)
>   at 
> org.apache.avro.specific.SpecificData$3.computeValue(SpecificData.java:335)
>   at 
> org.apache.avro.specific.SpecificData$3.computeValue(SpecificData.java:332)
> {noformat}
> From the log, you may see that: we should not handle Java hidden field 
> `this$0` which is used to hold reference to outer class instances.
> This issue is somehow related to [this 
> one|https://issues.apache.org/jira/browse/AVRO-2805]



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


[jira] [Work started] (AVRO-2808) Java: ReflectData incorrectly handles hidden fields

2020-05-08 Thread Andy Le (Jira)


 [ 
https://issues.apache.org/jira/browse/AVRO-2808?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Work on AVRO-2808 started by Andy Le.
-
> Java: ReflectData incorrectly handles hidden fields
> ---
>
> Key: AVRO-2808
> URL: https://issues.apache.org/jira/browse/AVRO-2808
> Project: Apache Avro
>  Issue Type: Improvement
>  Components: java
>Affects Versions: 1.9.2
>Reporter: Andy Le
>Assignee: Andy Le
>Priority: Major
>
> Hi guys,
> I've got the following test:
> {code:java}
> public ReflectTest{
>   public class Definition {
> public Map tokens;
>   }
>   public enum Type {
> A,
> B,
> C
>   }
>   @Test
>   public void testAvro2805() {
> Schema schema = ReflectData.get().getSchema(Definition.class);
> final String schemaString = schema.toString(true);
> System.out.println(schemaString);
>   }
> }
> {code}
> When I ran the test, an exception is raised:
> {noformat}
> org.apache.avro.SchemaParseException: Illegal character in: this$0
>   at org.apache.avro.Schema.validateName(Schema.java:1530)
>   at org.apache.avro.Schema.access$400(Schema.java:87)
>   at org.apache.avro.Schema$Field.(Schema.java:518)
>   at org.apache.avro.Schema$Field.(Schema.java:557)
>   at 
> org.apache.avro.reflect.ReflectData.createSchema(ReflectData.java:683)
>   at 
> org.apache.avro.specific.SpecificData$3.computeValue(SpecificData.java:335)
>   at 
> org.apache.avro.specific.SpecificData$3.computeValue(SpecificData.java:332)
> {noformat}
> From the log, you may see that: we should not handle Java hidden field 
> `this$0` which is used to hold reference to outer class instances.
> This issue is somehow related to [this 
> one|https://issues.apache.org/jira/browse/AVRO-2805]



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


[jira] [Assigned] (AVRO-2808) Java: ReflectData incorrectly handles hidden fields

2020-05-08 Thread Andy Le (Jira)


 [ 
https://issues.apache.org/jira/browse/AVRO-2808?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Andy Le reassigned AVRO-2808:
-

Assignee: Andy Le

> Java: ReflectData incorrectly handles hidden fields
> ---
>
> Key: AVRO-2808
> URL: https://issues.apache.org/jira/browse/AVRO-2808
> Project: Apache Avro
>  Issue Type: Bug
>  Components: java
>Affects Versions: 1.9.2
>Reporter: Andy Le
>Assignee: Andy Le
>Priority: Major
>
> Hi guys,
> I've got the following test:
> {code:java}
> public ReflectTest{
>   public class Definition {
> public Map tokens;
>   }
>   public enum Type {
> A,
> B,
> C
>   }
>   @Test
>   public void testAvro2805() {
> Schema schema = ReflectData.get().getSchema(Definition.class);
> final String schemaString = schema.toString(true);
> System.out.println(schemaString);
>   }
> }
> {code}
> When I ran the test, an exception is raised:
> {noformat}
> org.apache.avro.SchemaParseException: Illegal character in: this$0
>   at org.apache.avro.Schema.validateName(Schema.java:1530)
>   at org.apache.avro.Schema.access$400(Schema.java:87)
>   at org.apache.avro.Schema$Field.(Schema.java:518)
>   at org.apache.avro.Schema$Field.(Schema.java:557)
>   at 
> org.apache.avro.reflect.ReflectData.createSchema(ReflectData.java:683)
>   at 
> org.apache.avro.specific.SpecificData$3.computeValue(SpecificData.java:335)
>   at 
> org.apache.avro.specific.SpecificData$3.computeValue(SpecificData.java:332)
> {noformat}
> From the log, you may see that: we should not handle Java hidden field 
> `this$0` which is used to hold reference to outer class instances.
> This issue is somehow related to [this 
> one|https://issues.apache.org/jira/browse/AVRO-2805]



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


[GitHub] [avro] anhldbk opened a new pull request #874: AVRO-2808: provide details while encountering non-static inner classes

2020-05-08 Thread GitBox


anhldbk opened a new pull request #874:
URL: https://github.com/apache/avro/pull/874


   Make sure you have checked _all_ steps below.
   
   ### Jira
   
   - [ ] My PR addresses the following [Avro 
Jira](https://issues.apache.org/jira/browse/AVRO/) issues and references them 
in the PR title.
 - https://issues.apache.org/jira/browse/AVRO-2808
 - In case you are adding a dependency, check if the license complies with 
the [ASF 3rd Party License 
Policy](https://www.apache.org/legal/resolved.html#category-x).
   
   ### Tests
   
   - [x] My PR adds the following unit tests `TestReflectData.testInnerClasses`
   
   ### Commits
   
   - [x] My commits all reference Jira issues in their subject lines. In 
addition, my commits follow the guidelines from "[How to write a good git 
commit message](https://chris.beams.io/posts/git-commit/)":
 1. Subject is separated from body by a blank line
 1. Subject is limited to 50 characters (not including Jira issue reference)
 1. Subject does not end with a period
 1. Subject uses the imperative mood ("add", not "adding")
 1. Body wraps at 72 characters
 1. Body explains "what" and "why", not "how"
   
   ### Documentation
   
   - [x] In case of new functionality, my PR adds documentation that describes 
how to use it.
 - All the public functions and the classes in the PR contain Javadoc that 
explain what it does
   



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[jira] [Commented] (AVRO-2278) GenericData.Record field getter not correct

2020-05-08 Thread Andy Le (Jira)


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

Andy Le commented on AVRO-2278:
---

[~zolyfarkas] [~rskraba] I think there are 2 other options:
 * Opt #1. Introduce Schema.exist(key) to verify if a key is valid, no change 
to Schema.get(key)
 * Opt #2. Introduce a more consistent way in Schema.fetch(key) and mark 
Schema.get(key) as deprecated.

> GenericData.Record field getter not correct
> ---
>
> Key: AVRO-2278
> URL: https://issues.apache.org/jira/browse/AVRO-2278
> Project: Apache Avro
>  Issue Type: Bug
>  Components: java
>Affects Versions: 1.8.2, 1.9.2
>Reporter: Zoltan Farkas
>Assignee: Zoltan Farkas
>Priority: Major
>
> Currently the get field implementation is not correct in GenericData.Record:
> at: 
> https://github.com/apache/avro/blob/master/lang/java/avro/src/main/java/org/apache/avro/generic/GenericData.java#L209
> {code}
>@Override public Object get(String key) {
>   Field field = schema.getField(key);
>   if (field == null) return null;
>   return values[field.pos()];
> }
> {code}
> The method returns null when a field is not present, making it impossible to 
> distinguish between:
> field value = null
> and
> field does not exist.
> A more "correct" implementation would be:
> {code}
> @Override public Object get(String key) {
>   Field field = schema.getField(key);
>   if (field == null) {
> throw new IllegalArgumentException("Invalid field " + key);
>   }
>   return values[field.pos()];
> }
> {code}
> this will make the behavior consistent with put which will throw a exception 
> when setting a non existent field.
> when I make this change in my fork, some bugs in unit tests showed up



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


[GitHub] [avro] anhldbk commented on pull request #290: AVRO-1954 - Schema.Field.defaultVal() generates: Unknown datum type org.apache.avro.JsonProperties$Null

2020-05-08 Thread GitBox


anhldbk commented on pull request #290:
URL: https://github.com/apache/avro/pull/290#issuecomment-625752728


   @gopipofficial any sample code?



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [avro] gopipofficial commented on pull request #290: AVRO-1954 - Schema.Field.defaultVal() generates: Unknown datum type org.apache.avro.JsonProperties$Null

2020-05-08 Thread GitBox


gopipofficial commented on pull request #290:
URL: https://github.com/apache/avro/pull/290#issuecomment-625731714


   hi Team,
   I'm facing an issue similar to this  can some one help me to fix this? below 
is the error messsage
   "AvroRuntimeException: Unknown datum type 
org.apache.avro.JsonProperties$Null: 
org.apache.avro.JsonProperties$Null@7714e963"



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org