Uploaded image for project: 'Apache Avro'
  1. Apache Avro
  2. AVRO-2778

Java: Reflect raises exceptions while dealing with non-static classes

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Duplicate
    • 1.9.2
    • None
    • java
    • None

    Description

      Hi guys,

      I've got the following simple code:

      public class TestReflect {
        public class Human{
          String name = "Andy";
        }
      
        @Test
        public void testNonStaticClasses(){
          ReflectData.get().getSchema(Human.class) ;
        }
      
      }
      

      When I run the test, an exception is spawn:

      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.<init>(Schema.java:518)
      	at org.apache.avro.Schema$Field.<init>(Schema.java:557)
      	at org.apache.avro.reflect.ReflectData.createSchema(ReflectData.java:645)
      	at org.apache.avro.specific.SpecificData$3.computeValue(SpecificData.java:335)
      	at org.apache.avro.specific.SpecificData$3.computeValue(SpecificData.java:1)
      	at java.lang.ClassValue.getFromHashMap(ClassValue.java:227)
      	at java.lang.ClassValue.getFromBackup(ClassValue.java:209)
      	at java.lang.ClassValue.get(ClassValue.java:115)
      	at org.apache.avro.specific.SpecificData.getSchema(SpecificData.java:346)
              ...
      

      It seems to me that: Avro Reflect does NOT effectively handle non-static classes.

      Should I make a PR against this issue?

      Attachments

        Activity

          People

            anhldbk Andy Le
            anhldbk Andy Le
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: