0

(apache avro 1.8.2, avro-maven-plugin 1.8.2)

I'm having problem with avro:schema.

I declared a field like under below

{
            "name": "type",
            "type": {
                "type": "string",
                "avro.java.string": "java.lang.String"
            }
        },

but avro:schema converts like

@Deprecated public java.lang.CharSequence type;

...

public OptionDetail(..., java.lang.CharSequence type, ...) {
    ...
    this.type = type;
    ...
  }

What I tried:

  1. "avro.java.string": "java.lang.String"
  2. (pom.xml, )
<stringType>String</stringType>

Both of above doesn't work properly. Please let me know what should I try more. Thanks.

  • 1
    `CharSequence` is just the interface for `java.lang.String`. Most likely, your framework is just trying to code to an interface, rather than returning you an implementation. My advice: maybe don't even attempt what you are doing. – Tim Biegeleisen Dec 14 '20 at 05:12
  • 1
    @TimBiegeleisen I generally agree with you, but if `CharSequence` is the _return_ type of a property (or in this case, of a public field), it'll be a hassle to interoperate with everything else that expects `String`. – chrylis -cautiouslyoptimistic- Dec 14 '20 at 05:20

2 Answers2

0

Have you tried upgrading to Avro version 1.10.0? I don't see the issue in this version. Setting the stringType field in the pom fixed it for me, so I expect it's just a version problem.

icecreamhead
  • 111
  • 1
  • 12
0

If you want all you string fields be instances of java.lang.String then you only have to configure the compiler:

java -jar /path/to/avro-tools-1.7.7.jar compile -string schema 

or if you are using the Maven plugin

<plugin>
  <groupId>org.apache.avro</groupId>
  <artifactId>avro-maven-plugin</artifactId>
  <version>1.7.7</version>
  <configuration>
    <stringType>String</stringType>
  </configuration>
  [...]
</plugin>        

More details: https://stackoverflow.com/a/25315412/2945616

Radix
  • 2,527
  • 1
  • 19
  • 43